mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 18:22:14 +00:00
the end of sern init??
This commit is contained in:
@@ -7,10 +7,7 @@ export function makePlugin<V extends unknown[]>(
|
||||
type: PluginType,
|
||||
execute: (...args: any[]) => any,
|
||||
): Plugin<V> {
|
||||
return {
|
||||
type,
|
||||
execute,
|
||||
} as Plugin<V>;
|
||||
return { type, execute, } as Plugin<V>;
|
||||
}
|
||||
/**
|
||||
* @since 2.5.0
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as assert from 'assert';
|
||||
import { useContainer } from './dependency-injection';
|
||||
import type { CoreDependencies, DependencyConfiguration } from '../../types/ioc';
|
||||
import { CoreContainer } from './container';
|
||||
import { Result } from 'ts-results-es';
|
||||
@@ -141,7 +140,7 @@ function composeRoot(
|
||||
container.ready();
|
||||
}
|
||||
|
||||
export async function makeDependencies<const T extends Dependencies>
|
||||
export async function makeDependencies
|
||||
(conf: ValidDependencyConfig) {
|
||||
containerSubject = new CoreContainer();
|
||||
if(typeof conf === 'function') {
|
||||
@@ -160,7 +159,5 @@ export async function makeDependencies<const T extends Dependencies>
|
||||
} else {
|
||||
composeRoot(containerSubject, conf);
|
||||
}
|
||||
|
||||
return useContainer<T>();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,3 @@ export function Services<const T extends (keyof Dependencies)[]>(...keys: [...T]
|
||||
const container = useContainerRaw();
|
||||
return keys.map(k => container.get(k)!) as IntoDependencies<T>;
|
||||
}
|
||||
|
||||
|
||||
export function useContainer<const T extends Dependencies>() {
|
||||
return <V extends (keyof T)[]>(...keys: [...V]) =>
|
||||
keys.map(key => useContainerRaw().get(key as keyof Dependencies)) as IntoDependencies<V>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from 'node:path';
|
||||
import assert from 'assert';
|
||||
import { createRequire } from 'node:module';
|
||||
import type { ImportPayload, Wrapper } from '../types/core';
|
||||
import type { Wrapper } from '../types/core';
|
||||
import { existsSync } from 'fs';
|
||||
import type { Logging } from './interfaces';
|
||||
|
||||
@@ -17,7 +17,7 @@ export const parseCallsite = (fpath: string) => {
|
||||
export const shouldHandle = (pth: string, filenam: string) => {
|
||||
const file_name = filenam+path.extname(pth);
|
||||
let newPath = path.join(path.dirname(pth), file_name)
|
||||
.replace(/file:\\?/, "");
|
||||
.replace(/file:\\?/, "");
|
||||
return { exists: existsSync(newPath),
|
||||
path: 'file:///'+newPath };
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export async function importModule<T>(absPath: string) {
|
||||
|
||||
let commandModule = fileModule.default;
|
||||
|
||||
assert(commandModule , `Found no export @ ${absPath}. Forgot to ignore with "!"? (!${path.basename(absPath)})?`);
|
||||
assert(commandModule , `No export @ ${absPath}. Forgot to ignore with "!"? (!${path.basename(absPath)})?`);
|
||||
if ('default' in commandModule) {
|
||||
commandModule = commandModule.default;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user