From 9faae7eca7a03ce4b2ae158e55e57c00b767b182 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 28 Apr 2024 20:36:50 -0500 Subject: [PATCH] consolidate default services in single file --- src/core/_internal.ts | 2 +- .../logger.ts => default-services.ts} | 22 ++++++++++++++++++- src/core/structures/index.ts | 2 +- .../structures/services/error-handling.ts | 21 ------------------ src/core/structures/services/index.ts | 2 -- src/types/core-plugin.ts | 2 +- src/types/core.ts | 11 ---------- 7 files changed, 24 insertions(+), 38 deletions(-) rename src/core/structures/{services/logger.ts => default-services.ts} (60%) delete mode 100644 src/core/structures/services/error-handling.ts delete mode 100644 src/core/structures/services/index.ts diff --git a/src/core/_internal.ts b/src/core/_internal.ts index be7f2a5..3504597 100644 --- a/src/core/_internal.ts +++ b/src/core/_internal.ts @@ -5,7 +5,7 @@ export * from './operators'; export * as Files from './module-loading'; export * from './functions'; export { SernError } from './structures/enums'; -export * as __Services from './structures/services'; +export { __Services } from './structures'; export { useContainerRaw } from './ioc/base'; export type _Module = { diff --git a/src/core/structures/services/logger.ts b/src/core/structures/default-services.ts similarity index 60% rename from src/core/structures/services/logger.ts rename to src/core/structures/default-services.ts index 9459791..c4c1169 100644 --- a/src/core/structures/services/logger.ts +++ b/src/core/structures/default-services.ts @@ -1,4 +1,24 @@ -import { LogPayload, Logging } from '../../interfaces'; +import type { LogPayload, Logging, ErrorHandling } from '../interfaces'; +/** + * @internal + * @since 2.0.0 + * Version 4.0.0 will internalize this api. Please refrain from using the defaults! + */ +export class DefaultErrorHandling implements ErrorHandling { + crash(err: Error): never { + throw err; + } + + #keepAlive = 1; + + updateAlive(err: Error) { + this.#keepAlive--; + if (this.#keepAlive === 0) { + throw err; + } + } +} + /** * @internal diff --git a/src/core/structures/index.ts b/src/core/structures/index.ts index 64b8755..1a715ae 100644 --- a/src/core/structures/index.ts +++ b/src/core/structures/index.ts @@ -1,4 +1,4 @@ export { CommandType, PluginType, PayloadType, EventType } from './enums'; export * from './context'; -export * from './services'; +export * as __Services from './default-services'; diff --git a/src/core/structures/services/error-handling.ts b/src/core/structures/services/error-handling.ts deleted file mode 100644 index 7f53117..0000000 --- a/src/core/structures/services/error-handling.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ErrorHandling } from '../../interfaces'; - -/** - * @internal - * @since 2.0.0 - * Version 4.0.0 will internalize this api. Please refrain from using the defaults! - */ -export class DefaultErrorHandling implements ErrorHandling { - crash(err: Error): never { - throw err; - } - - #keepAlive = 1; - - updateAlive(err: Error) { - this.#keepAlive--; - if (this.#keepAlive === 0) { - throw err; - } - } -} diff --git a/src/core/structures/services/index.ts b/src/core/structures/services/index.ts deleted file mode 100644 index 3074d8f..0000000 --- a/src/core/structures/services/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './error-handling'; -export * from './logger'; diff --git a/src/types/core-plugin.ts b/src/types/core-plugin.ts index ae92c68..3d08899 100644 --- a/src/types/core-plugin.ts +++ b/src/types/core-plugin.ts @@ -11,7 +11,7 @@ * Plugins are reminiscent of middleware in express. */ -import type { Err, Ok, Result } from 'ts-results-es'; +import type { Err, Ok } from 'ts-results-es'; import type { BothCommand, ButtonCommand, diff --git a/src/types/core.ts b/src/types/core.ts index 0985d60..e388cf7 100644 --- a/src/types/core.ts +++ b/src/types/core.ts @@ -9,15 +9,4 @@ export interface Wrapper { commands: string; defaultPrefix?: string; events?: string; - /** - * Overload to enable mode in case developer does not use a .env file. - * @deprecated - https://github.com/sern-handler/handler/pull/325 - */ - mode?: string - /* - * @deprecated - */ - containerConfig?: { - get: (...keys: (keyof Dependencies)[]) => unknown[]; - }; }