mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 18:22:14 +00:00
up to speed with event modules
This commit is contained in:
@@ -4,6 +4,7 @@ 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';
|
||||
|
||||
export function disposeAll(logger: Logging|undefined) {
|
||||
useContainerRaw()
|
||||
@@ -72,6 +73,7 @@ async function composeRoot(
|
||||
__add_container('@sern/errors', new __Services.DefaultErrorHandling());
|
||||
__add_container('@sern/cron', {})
|
||||
__add_container('@sern/modules', new Map())
|
||||
__add_container('@sern/emitter', new EventEmitter())
|
||||
//Build the container based on the callback provided by the user
|
||||
conf.build(container as Container);
|
||||
|
||||
@@ -97,6 +99,8 @@ export async function makeDependencies (conf: ValidDependencyConfig) {
|
||||
}
|
||||
__add_container('@sern/errors', new __Services.DefaultErrorHandling());
|
||||
__add_container('@sern/cron', {})
|
||||
__add_container('@sern/modules', new Map())
|
||||
__add_container('@sern/emitter', new EventEmitter())
|
||||
await useContainerRaw().ready();
|
||||
} else {
|
||||
await composeRoot(useContainerRaw(), conf);
|
||||
|
||||
@@ -59,7 +59,7 @@ export async function* readRecursive(dir: string): AsyncGenerator<string> {
|
||||
const files = await readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const file of files) {
|
||||
const fullPath = path.join(dir, file.name);
|
||||
const fullPath = path.posix.resolve(dir, file.name);
|
||||
if (file.isDirectory()) {
|
||||
if (!file.name.startsWith('!')) {
|
||||
yield* readRecursive(fullPath);
|
||||
|
||||
@@ -73,9 +73,9 @@ export function handleError<C>(crashHandler: ErrorHandling, emitter: Emitter, lo
|
||||
//// Temporary until i get rxjs operators working on ts-results-es
|
||||
export const filterTap = <K, R>(onErr: (e: R) => void): OperatorFunction<Result<K, R>, K> =>
|
||||
concatMap(result => {
|
||||
if(result.isOk()) {
|
||||
return of(result.value)
|
||||
}
|
||||
onErr(result.error);
|
||||
return EMPTY
|
||||
if(result.isOk()) {
|
||||
return of(result.value)
|
||||
}
|
||||
onErr(result.error);
|
||||
return EMPTY;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user