mirror of
https://github.com/sern-handler/handler
synced 2026-06-16 12:52:15 +00:00
ksdjkldsfld
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import type { DependencyConfiguration } from '../../types/ioc';
|
||||
import { Container } from './container';
|
||||
import * as __Services from '../structures/default-services';
|
||||
import { UnpackedDependencies } from '../../types/utility';
|
||||
import type { Logging } from '../interfaces';
|
||||
import { __add_container, __init_container, __swap_container, useContainerRaw } from './global';
|
||||
import { EventEmitter } from 'node:events';
|
||||
@@ -14,7 +13,7 @@ export function disposeAll(logger: Logging|undefined) {
|
||||
|
||||
|
||||
type Insertable =
|
||||
| ((container: UnpackedDependencies) => object)
|
||||
| ((container: Dependencies) => object)
|
||||
| object
|
||||
const dependencyBuilder = (container: Container, excluded: string[] ) => {
|
||||
return {
|
||||
@@ -26,7 +25,8 @@ const dependencyBuilder = (container: Container, excluded: string[] ) => {
|
||||
if(typeof v !== 'function') {
|
||||
container.addSingleton(key, v)
|
||||
} else {
|
||||
container.addWiredSingleton(key, (cntr) => v(cntr as UnpackedDependencies))
|
||||
//@ts-ignore
|
||||
container.addWiredSingleton(key, (cntr) => v(cntr))
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -53,7 +53,6 @@ const dependencyBuilder = (container: Container, excluded: string[] ) => {
|
||||
type ValidDependencyConfig =
|
||||
| ((c: ReturnType<typeof dependencyBuilder>) => any)
|
||||
| DependencyConfiguration;
|
||||
|
||||
|
||||
/**
|
||||
* Given the user's conf, check for any excluded/included dependency keys.
|
||||
@@ -79,13 +78,14 @@ async function composeRoot(
|
||||
|
||||
if (!hasLogger) {
|
||||
container.get<Logging>('@sern/logger')
|
||||
?.info({ message: 'All dependencies loaded successfully.' });
|
||||
?.info({ message: 'All dependencies loaded successfully.' });
|
||||
}
|
||||
container.ready();
|
||||
await container.ready();
|
||||
}
|
||||
|
||||
export async function makeDependencies (conf: ValidDependencyConfig) {
|
||||
await __init_container({ autowire: false });
|
||||
|
||||
if(typeof conf === 'function') {
|
||||
const excluded: string[] = [];
|
||||
conf(dependencyBuilder(useContainerRaw(), excluded));
|
||||
|
||||
@@ -35,14 +35,12 @@ interface PluginExecutable {
|
||||
* Calls any plugin with {args}.
|
||||
* @param args if an array, its spread and plugin called.
|
||||
*/
|
||||
export function callPlugin(args: unknown): OperatorFunction<PluginExecutable, VoidResult>
|
||||
export function callPlugin(plugin: PluginExecutable, args: unknown)
|
||||
{
|
||||
return concatMap(async plugin => {
|
||||
if (Array.isArray(args)) {
|
||||
return plugin.execute(...args);
|
||||
}
|
||||
return plugin.execute(args);
|
||||
});
|
||||
if (Array.isArray(args)) {
|
||||
return plugin.execute(...args);
|
||||
}
|
||||
return plugin.execute(args);
|
||||
}
|
||||
|
||||
export const arrayifySource = <T>(src: T) =>
|
||||
@@ -52,7 +50,7 @@ export const arrayifySource = <T>(src: T) =>
|
||||
* Checks if the stream of results is all ok.
|
||||
*/
|
||||
export const everyPluginOk: OperatorFunction<VoidResult, boolean> =
|
||||
pipe(every(result => result.isOk()),
|
||||
pipe(every(result => result.isOk()), //this shortcircuits
|
||||
defaultIfEmpty(true));
|
||||
|
||||
export const sharedEventStream = <T>(e: Emitter, eventName: string) =>
|
||||
|
||||
@@ -61,7 +61,7 @@ export class Cron extends EventEmitter {
|
||||
|
||||
//@ts-ignore
|
||||
if(!cron.validate(module.pattern)) {
|
||||
throw Error("Invalid cron expression while adding")
|
||||
throw Error("Invalid cron expression while adding " + module.name)
|
||||
}
|
||||
this.modules.set(module.name!, module as CronEventCommand);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user