@navios/core 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/{index-BFwNx9WQ.d.cts → index-DW9EPAE6.d.mts} +222 -17
- package/lib/index-DW9EPAE6.d.mts.map +1 -0
- package/lib/{index-D657ijFO.d.mts → index-pHp-dIGt.d.cts} +222 -17
- package/lib/index-pHp-dIGt.d.cts.map +1 -0
- package/lib/index.cjs +5 -5
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +1 -1
- package/lib/legacy-compat/index.cjs +1 -1
- package/lib/legacy-compat/index.d.cts +1 -1
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +1 -1
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/{src-DzPY5s6d.mjs → src-DyvCDuKO.mjs} +121 -31
- package/lib/src-DyvCDuKO.mjs.map +1 -0
- package/lib/{src-Cb1aTjl0.cjs → src-QnxR5b7c.cjs} +164 -74
- package/lib/src-QnxR5b7c.cjs.map +1 -0
- package/lib/testing/index.cjs +6 -6
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.mjs +1 -1
- package/lib/{use-guards.decorator-DdvUhB03.cjs → use-guards.decorator-B6q_N0sf.cjs} +17 -17
- package/lib/{use-guards.decorator-DdvUhB03.cjs.map → use-guards.decorator-B6q_N0sf.cjs.map} +1 -1
- package/package.json +12 -12
- package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
- package/src/interfaces/index.mts +1 -0
- package/src/interfaces/plugin.interface.mts +105 -0
- package/src/logger/logger.service.mts +5 -3
- package/src/navios.application.mts +77 -27
- package/src/navios.factory.mts +10 -9
- package/src/services/module-loader.service.mts +102 -1
- package/lib/index-BFwNx9WQ.d.cts.map +0 -1
- package/lib/index-D657ijFO.d.mts.map +0 -1
- package/lib/src-Cb1aTjl0.cjs.map +0 -1
- package/lib/src-DzPY5s6d.mjs.map +0 -1
- package/src/attribute.factory.d.mts +0 -175
- package/src/attribute.factory.d.mts.map +0 -1
- package/src/config/config-service.interface.d.mts +0 -39
- package/src/config/config-service.interface.d.mts.map +0 -1
- package/src/config/config.provider.d.mts +0 -46
- package/src/config/config.provider.d.mts.map +0 -1
- package/src/config/config.service.d.mts +0 -108
- package/src/config/config.service.d.mts.map +0 -1
- package/src/config/index.d.mts +0 -6
- package/src/config/index.d.mts.map +0 -1
- package/src/config/types.d.mts +0 -13
- package/src/config/types.d.mts.map +0 -1
- package/src/config/utils/helpers.d.mts +0 -3
- package/src/config/utils/helpers.d.mts.map +0 -1
- package/src/config/utils/index.d.mts +0 -2
- package/src/config/utils/index.d.mts.map +0 -1
- package/src/decorators/controller.decorator.d.mts +0 -33
- package/src/decorators/controller.decorator.d.mts.map +0 -1
- package/src/decorators/endpoint.decorator.d.mts +0 -89
- package/src/decorators/endpoint.decorator.d.mts.map +0 -1
- package/src/decorators/header.decorator.d.mts +0 -22
- package/src/decorators/header.decorator.d.mts.map +0 -1
- package/src/decorators/http-code.decorator.d.mts +0 -22
- package/src/decorators/http-code.decorator.d.mts.map +0 -1
- package/src/decorators/index.d.mts +0 -9
- package/src/decorators/index.d.mts.map +0 -1
- package/src/decorators/module.decorator.d.mts +0 -42
- package/src/decorators/module.decorator.d.mts.map +0 -1
- package/src/decorators/multipart.decorator.d.mts +0 -54
- package/src/decorators/multipart.decorator.d.mts.map +0 -1
- package/src/decorators/stream.decorator.d.mts +0 -42
- package/src/decorators/stream.decorator.d.mts.map +0 -1
- package/src/decorators/use-guards.decorator.d.mts +0 -33
- package/src/decorators/use-guards.decorator.d.mts.map +0 -1
- package/src/exceptions/bad-request.exception.d.mts +0 -26
- package/src/exceptions/bad-request.exception.d.mts.map +0 -1
- package/src/exceptions/conflict.exception.d.mts +0 -29
- package/src/exceptions/conflict.exception.d.mts.map +0 -1
- package/src/exceptions/forbidden.exception.d.mts +0 -28
- package/src/exceptions/forbidden.exception.d.mts.map +0 -1
- package/src/exceptions/http.exception.d.mts +0 -33
- package/src/exceptions/http.exception.d.mts.map +0 -1
- package/src/exceptions/index.d.mts +0 -8
- package/src/exceptions/index.d.mts.map +0 -1
- package/src/exceptions/internal-server-error.exception.d.mts +0 -31
- package/src/exceptions/internal-server-error.exception.d.mts.map +0 -1
- package/src/exceptions/not-found.exception.d.mts +0 -30
- package/src/exceptions/not-found.exception.d.mts.map +0 -1
- package/src/exceptions/unauthorized.exception.d.mts +0 -28
- package/src/exceptions/unauthorized.exception.d.mts.map +0 -1
- package/src/factories/endpoint-adapter.factory.d.mts +0 -6
- package/src/factories/endpoint-adapter.factory.d.mts.map +0 -1
- package/src/factories/http-adapter.factory.d.mts +0 -6
- package/src/factories/http-adapter.factory.d.mts.map +0 -1
- package/src/factories/index.d.mts +0 -8
- package/src/factories/index.d.mts.map +0 -1
- package/src/factories/multipart-adapter.factory.d.mts +0 -6
- package/src/factories/multipart-adapter.factory.d.mts.map +0 -1
- package/src/factories/reply.factory.d.mts +0 -6
- package/src/factories/reply.factory.d.mts.map +0 -1
- package/src/factories/request.factory.d.mts +0 -6
- package/src/factories/request.factory.d.mts.map +0 -1
- package/src/factories/stream-adapter.factory.d.mts +0 -6
- package/src/factories/stream-adapter.factory.d.mts.map +0 -1
- package/src/factories/xml-stream-adapter.factory.d.mts +0 -6
- package/src/factories/xml-stream-adapter.factory.d.mts.map +0 -1
- package/src/index.d.mts +0 -15
- package/src/index.d.mts.map +0 -1
- package/src/interfaces/abstract-execution-context.inteface.d.mts +0 -44
- package/src/interfaces/abstract-execution-context.inteface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-adapter.interface.d.mts +0 -15
- package/src/interfaces/abstract-http-adapter.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-cors-options.interface.d.mts +0 -58
- package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +0 -7
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-listen-options.interface.d.mts +0 -5
- package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +0 -1
- package/src/interfaces/can-activate.d.mts +0 -36
- package/src/interfaces/can-activate.d.mts.map +0 -1
- package/src/interfaces/http-header.d.mts +0 -10
- package/src/interfaces/http-header.d.mts.map +0 -1
- package/src/interfaces/index.d.mts +0 -9
- package/src/interfaces/index.d.mts.map +0 -1
- package/src/interfaces/navios-module.d.mts +0 -29
- package/src/interfaces/navios-module.d.mts.map +0 -1
- package/src/legacy-compat/context-compat.d.mts +0 -19
- package/src/legacy-compat/context-compat.d.mts.map +0 -1
- package/src/legacy-compat/decorators/controller.decorator.d.mts +0 -21
- package/src/legacy-compat/decorators/controller.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts +0 -33
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/header.decorator.d.mts +0 -24
- package/src/legacy-compat/decorators/header.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/http-code.decorator.d.mts +0 -22
- package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/index.d.mts +0 -9
- package/src/legacy-compat/decorators/index.d.mts.map +0 -1
- package/src/legacy-compat/decorators/module.decorator.d.mts +0 -22
- package/src/legacy-compat/decorators/module.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/multipart.decorator.d.mts +0 -34
- package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/stream.decorator.d.mts +0 -34
- package/src/legacy-compat/decorators/stream.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts +0 -29
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +0 -1
- package/src/legacy-compat/index.d.mts +0 -19
- package/src/legacy-compat/index.d.mts.map +0 -1
- package/src/logger/console-logger.service.d.mts +0 -196
- package/src/logger/console-logger.service.d.mts.map +0 -1
- package/src/logger/index.d.mts +0 -7
- package/src/logger/index.d.mts.map +0 -1
- package/src/logger/log-levels.d.mts +0 -14
- package/src/logger/log-levels.d.mts.map +0 -1
- package/src/logger/logger-service.interface.d.mts +0 -36
- package/src/logger/logger-service.interface.d.mts.map +0 -1
- package/src/logger/logger.service.d.mts +0 -57
- package/src/logger/logger.service.d.mts.map +0 -1
- package/src/logger/logger.tokens.d.mts +0 -36
- package/src/logger/logger.tokens.d.mts.map +0 -1
- package/src/logger/utils/cli-colors.util.d.mts +0 -10
- package/src/logger/utils/cli-colors.util.d.mts.map +0 -1
- package/src/logger/utils/filter-log-levelts.util.d.mts +0 -6
- package/src/logger/utils/filter-log-levelts.util.d.mts.map +0 -1
- package/src/logger/utils/index.d.mts +0 -6
- package/src/logger/utils/index.d.mts.map +0 -1
- package/src/logger/utils/is-log-level-enabled.d.mts +0 -8
- package/src/logger/utils/is-log-level-enabled.d.mts.map +0 -1
- package/src/logger/utils/is-log-level.util.d.mts +0 -6
- package/src/logger/utils/is-log-level.util.d.mts.map +0 -1
- package/src/logger/utils/shared.utils.d.mts +0 -14
- package/src/logger/utils/shared.utils.d.mts.map +0 -1
- package/src/metadata/controller.metadata.d.mts +0 -13
- package/src/metadata/controller.metadata.d.mts.map +0 -1
- package/src/metadata/handler.metadata.d.mts +0 -18
- package/src/metadata/handler.metadata.d.mts.map +0 -1
- package/src/metadata/index.d.mts +0 -4
- package/src/metadata/index.d.mts.map +0 -1
- package/src/metadata/module.metadata.d.mts +0 -13
- package/src/metadata/module.metadata.d.mts.map +0 -1
- package/src/navios.application.d.mts +0 -210
- package/src/navios.application.d.mts.map +0 -1
- package/src/navios.environment.d.mts +0 -11
- package/src/navios.environment.d.mts.map +0 -1
- package/src/navios.factory.d.mts +0 -68
- package/src/navios.factory.d.mts.map +0 -1
- package/src/services/guard-runner.service.d.mts +0 -10
- package/src/services/guard-runner.service.d.mts.map +0 -1
- package/src/services/index.d.mts +0 -3
- package/src/services/index.d.mts.map +0 -1
- package/src/services/module-loader.service.d.mts +0 -17
- package/src/services/module-loader.service.d.mts.map +0 -1
- package/src/stores/index.d.mts +0 -2
- package/src/stores/index.d.mts.map +0 -1
- package/src/stores/request-id.store.d.mts +0 -37
- package/src/stores/request-id.store.d.mts.map +0 -1
- package/src/tokens/endpoint-adapter.token.d.mts +0 -4
- package/src/tokens/endpoint-adapter.token.d.mts.map +0 -1
- package/src/tokens/execution-context.token.d.mts +0 -5
- package/src/tokens/execution-context.token.d.mts.map +0 -1
- package/src/tokens/http-adapter.token.d.mts +0 -4
- package/src/tokens/http-adapter.token.d.mts.map +0 -1
- package/src/tokens/index.d.mts +0 -9
- package/src/tokens/index.d.mts.map +0 -1
- package/src/tokens/multipart-adapter.token.d.mts +0 -4
- package/src/tokens/multipart-adapter.token.d.mts.map +0 -1
- package/src/tokens/reply.token.d.mts +0 -3
- package/src/tokens/reply.token.d.mts.map +0 -1
- package/src/tokens/request.token.d.mts +0 -3
- package/src/tokens/request.token.d.mts.map +0 -1
- package/src/tokens/stream-adapter.token.d.mts +0 -4
- package/src/tokens/stream-adapter.token.d.mts.map +0 -1
- package/src/tokens/xml-stream-adapter.token.d.mts +0 -4
- package/src/tokens/xml-stream-adapter.token.d.mts.map +0 -1
|
@@ -1021,6 +1021,8 @@ var LoggerInstance = class {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
log(message, ...optionalParams) {
|
|
1023
1023
|
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1024
|
+
console.log("log", message, optionalParams);
|
|
1025
|
+
console.log("localInstance", this.localInstance);
|
|
1024
1026
|
this.localInstance?.log(message, ...optionalParams);
|
|
1025
1027
|
}
|
|
1026
1028
|
warn(message, ...optionalParams) {
|
|
@@ -2300,6 +2302,49 @@ var ModuleLoaderService = class {
|
|
|
2300
2302
|
await this.traverseModules(appModule);
|
|
2301
2303
|
this.initialized = true;
|
|
2302
2304
|
}
|
|
2305
|
+
/**
|
|
2306
|
+
* Extends the module tree with additional modules or controllers.
|
|
2307
|
+
*
|
|
2308
|
+
* This method is designed to be called by plugins during registration,
|
|
2309
|
+
* which happens after initial module loading but before route registration.
|
|
2310
|
+
*
|
|
2311
|
+
* @param extensions - Array of module extensions to add
|
|
2312
|
+
* @throws Error if not initialized (loadModules must be called first)
|
|
2313
|
+
*
|
|
2314
|
+
* @example
|
|
2315
|
+
* ```typescript
|
|
2316
|
+
* // In plugin registration
|
|
2317
|
+
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
2318
|
+
* await moduleLoader.extendModules([{
|
|
2319
|
+
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
2320
|
+
* moduleName: 'OpenApiBunModule',
|
|
2321
|
+
* }])
|
|
2322
|
+
* ```
|
|
2323
|
+
*/ async extendModules(extensions) {
|
|
2324
|
+
if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
|
|
2325
|
+
for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
|
|
2326
|
+
else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
|
|
2327
|
+
else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* Registers controllers under a synthetic module.
|
|
2331
|
+
* Used when plugins want to add controllers without a full module class.
|
|
2332
|
+
*/ async registerControllers(controllers, moduleName) {
|
|
2333
|
+
if (this.modulesMetadata.has(moduleName)) {
|
|
2334
|
+
const existing = this.modulesMetadata.get(moduleName);
|
|
2335
|
+
for (const controller of controllers) existing.controllers.add(controller);
|
|
2336
|
+
this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
|
|
2337
|
+
} else {
|
|
2338
|
+
const metadata = {
|
|
2339
|
+
controllers: new Set(controllers),
|
|
2340
|
+
imports: /* @__PURE__ */ new Set(),
|
|
2341
|
+
guards: /* @__PURE__ */ new Set(),
|
|
2342
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
2343
|
+
};
|
|
2344
|
+
this.modulesMetadata.set(moduleName, metadata);
|
|
2345
|
+
this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2303
2348
|
async traverseModules(module, parentMetadata) {
|
|
2304
2349
|
const metadata = extractModuleMetadata(module);
|
|
2305
2350
|
if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
|
|
@@ -5097,6 +5142,7 @@ var NaviosApplication = class {
|
|
|
5097
5142
|
container = inject(Container);
|
|
5098
5143
|
appModule = null;
|
|
5099
5144
|
options = { adapter: [] };
|
|
5145
|
+
plugins = [];
|
|
5100
5146
|
/**
|
|
5101
5147
|
* Indicates whether the application has been initialized.
|
|
5102
5148
|
* Set to `true` after `init()` completes successfully.
|
|
@@ -5104,7 +5150,7 @@ var NaviosApplication = class {
|
|
|
5104
5150
|
/**
|
|
5105
5151
|
* Sets up the application with the provided module and options.
|
|
5106
5152
|
* This is called automatically by NaviosFactory.create().
|
|
5107
|
-
*
|
|
5153
|
+
*
|
|
5108
5154
|
* @param appModule - The root application module
|
|
5109
5155
|
* @param options - Application configuration options
|
|
5110
5156
|
* @internal
|
|
@@ -5115,24 +5161,46 @@ var NaviosApplication = class {
|
|
|
5115
5161
|
}
|
|
5116
5162
|
/**
|
|
5117
5163
|
* Gets the dependency injection container used by this application.
|
|
5118
|
-
*
|
|
5164
|
+
*
|
|
5119
5165
|
* @returns The Container instance
|
|
5120
5166
|
*/ getContainer() {
|
|
5121
5167
|
return this.container;
|
|
5122
5168
|
}
|
|
5123
5169
|
/**
|
|
5170
|
+
* Registers a plugin to be initialized after modules are loaded.
|
|
5171
|
+
*
|
|
5172
|
+
* Plugins are initialized in the order they are registered,
|
|
5173
|
+
* after all modules are loaded but before the server starts listening.
|
|
5174
|
+
*
|
|
5175
|
+
* @param definition - Plugin definition with options
|
|
5176
|
+
* @returns this for method chaining
|
|
5177
|
+
*
|
|
5178
|
+
* @example
|
|
5179
|
+
* ```typescript
|
|
5180
|
+
* import { defineOpenApiPlugin } from '@navios/openapi-fastify'
|
|
5181
|
+
*
|
|
5182
|
+
* app.usePlugin(defineOpenApiPlugin({
|
|
5183
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
5184
|
+
* }))
|
|
5185
|
+
* ```
|
|
5186
|
+
*/ usePlugin(definition) {
|
|
5187
|
+
this.plugins.push(definition);
|
|
5188
|
+
return this;
|
|
5189
|
+
}
|
|
5190
|
+
/**
|
|
5124
5191
|
* Initializes the application.
|
|
5125
|
-
*
|
|
5192
|
+
*
|
|
5126
5193
|
* This method:
|
|
5127
5194
|
* - Loads all modules and their dependencies
|
|
5128
5195
|
* - Sets up the HTTP server if an adapter is configured
|
|
5129
5196
|
* - Calls onModuleInit hooks on all modules
|
|
5197
|
+
* - Initializes registered plugins
|
|
5130
5198
|
* - Marks the application as initialized
|
|
5131
|
-
*
|
|
5199
|
+
*
|
|
5132
5200
|
* Must be called before `listen()`.
|
|
5133
|
-
*
|
|
5201
|
+
*
|
|
5134
5202
|
* @throws Error if app module is not set
|
|
5135
|
-
*
|
|
5203
|
+
*
|
|
5136
5204
|
* @example
|
|
5137
5205
|
* ```typescript
|
|
5138
5206
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5145,6 +5213,7 @@ var NaviosApplication = class {
|
|
|
5145
5213
|
if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
|
|
5146
5214
|
await this.moduleLoader.loadModules(this.appModule);
|
|
5147
5215
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
|
|
5216
|
+
await this.initPlugins();
|
|
5148
5217
|
await this.initModules();
|
|
5149
5218
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
|
|
5150
5219
|
this.isInitialized = true;
|
|
@@ -5154,12 +5223,30 @@ var NaviosApplication = class {
|
|
|
5154
5223
|
const modules = this.moduleLoader.getAllModules();
|
|
5155
5224
|
await this.httpApplication?.onModulesInit(modules);
|
|
5156
5225
|
}
|
|
5226
|
+
async initPlugins() {
|
|
5227
|
+
if (this.plugins.length === 0) return;
|
|
5228
|
+
let server = null;
|
|
5229
|
+
try {
|
|
5230
|
+
server = this.httpApplication?.getServer() ?? null;
|
|
5231
|
+
} catch {}
|
|
5232
|
+
const context = {
|
|
5233
|
+
modules: this.moduleLoader.getAllModules(),
|
|
5234
|
+
server,
|
|
5235
|
+
container: this.container,
|
|
5236
|
+
globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
|
|
5237
|
+
moduleLoader: this.moduleLoader
|
|
5238
|
+
};
|
|
5239
|
+
for (const { plugin, options } of this.plugins) {
|
|
5240
|
+
this.logger.debug(`Initializing plugin: ${plugin.name}`);
|
|
5241
|
+
await plugin.register(context, options);
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5157
5244
|
/**
|
|
5158
5245
|
* Enables CORS (Cross-Origin Resource Sharing) for the application.
|
|
5159
|
-
*
|
|
5246
|
+
*
|
|
5160
5247
|
* @param options - CORS configuration options (adapter-specific)
|
|
5161
5248
|
* @throws Error if HTTP application is not set
|
|
5162
|
-
*
|
|
5249
|
+
*
|
|
5163
5250
|
* @example
|
|
5164
5251
|
* ```typescript
|
|
5165
5252
|
* app.enableCors({
|
|
@@ -5174,10 +5261,10 @@ var NaviosApplication = class {
|
|
|
5174
5261
|
}
|
|
5175
5262
|
/**
|
|
5176
5263
|
* Enables multipart/form-data support for file uploads.
|
|
5177
|
-
*
|
|
5264
|
+
*
|
|
5178
5265
|
* @param options - Multipart configuration options (adapter-specific)
|
|
5179
5266
|
* @throws Error if HTTP application is not set
|
|
5180
|
-
*
|
|
5267
|
+
*
|
|
5181
5268
|
* @example
|
|
5182
5269
|
* ```typescript
|
|
5183
5270
|
* app.enableMultipart({
|
|
@@ -5192,10 +5279,10 @@ var NaviosApplication = class {
|
|
|
5192
5279
|
}
|
|
5193
5280
|
/**
|
|
5194
5281
|
* Sets a global prefix for all routes.
|
|
5195
|
-
*
|
|
5282
|
+
*
|
|
5196
5283
|
* @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
|
|
5197
5284
|
* @throws Error if HTTP application is not set
|
|
5198
|
-
*
|
|
5285
|
+
*
|
|
5199
5286
|
* @example
|
|
5200
5287
|
* ```typescript
|
|
5201
5288
|
* app.setGlobalPrefix('/api/v1')
|
|
@@ -5207,14 +5294,14 @@ var NaviosApplication = class {
|
|
|
5207
5294
|
}
|
|
5208
5295
|
/**
|
|
5209
5296
|
* Gets the underlying HTTP server instance.
|
|
5210
|
-
*
|
|
5297
|
+
*
|
|
5211
5298
|
* The type of the returned server depends on the adapter used:
|
|
5212
5299
|
* - Fastify adapter: Returns FastifyInstance
|
|
5213
5300
|
* - Bun adapter: Returns Bun.Server
|
|
5214
|
-
*
|
|
5301
|
+
*
|
|
5215
5302
|
* @returns The HTTP server instance
|
|
5216
5303
|
* @throws Error if HTTP application is not set
|
|
5217
|
-
*
|
|
5304
|
+
*
|
|
5218
5305
|
* @example
|
|
5219
5306
|
* ```typescript
|
|
5220
5307
|
* const server = app.getServer()
|
|
@@ -5226,10 +5313,10 @@ var NaviosApplication = class {
|
|
|
5226
5313
|
}
|
|
5227
5314
|
/**
|
|
5228
5315
|
* Starts the HTTP server and begins listening for requests.
|
|
5229
|
-
*
|
|
5316
|
+
*
|
|
5230
5317
|
* @param options - Listen options (port, host, etc.)
|
|
5231
5318
|
* @throws Error if HTTP application is not set
|
|
5232
|
-
*
|
|
5319
|
+
*
|
|
5233
5320
|
* @example
|
|
5234
5321
|
* ```typescript
|
|
5235
5322
|
* await app.listen({ port: 3000, host: '0.0.0.0' })
|
|
@@ -5240,7 +5327,7 @@ var NaviosApplication = class {
|
|
|
5240
5327
|
}
|
|
5241
5328
|
/**
|
|
5242
5329
|
* Disposes of application resources.
|
|
5243
|
-
*
|
|
5330
|
+
*
|
|
5244
5331
|
* Cleans up the HTTP server and module loader.
|
|
5245
5332
|
* This method is called automatically by `close()`.
|
|
5246
5333
|
*/ async dispose() {
|
|
@@ -5249,9 +5336,9 @@ var NaviosApplication = class {
|
|
|
5249
5336
|
}
|
|
5250
5337
|
/**
|
|
5251
5338
|
* Closes the application and cleans up all resources.
|
|
5252
|
-
*
|
|
5339
|
+
*
|
|
5253
5340
|
* This is an alias for `dispose()`.
|
|
5254
|
-
*
|
|
5341
|
+
*
|
|
5255
5342
|
* @example
|
|
5256
5343
|
* ```typescript
|
|
5257
5344
|
* // Graceful shutdown
|
|
@@ -5272,31 +5359,31 @@ var NaviosApplication = class {
|
|
|
5272
5359
|
//#region src/navios.factory.mts
|
|
5273
5360
|
/**
|
|
5274
5361
|
* Factory class for creating and configuring Navios applications.
|
|
5275
|
-
*
|
|
5362
|
+
*
|
|
5276
5363
|
* This is the main entry point for bootstrapping a Navios application.
|
|
5277
5364
|
* It handles dependency injection container setup, adapter registration,
|
|
5278
5365
|
* and logger configuration.
|
|
5279
|
-
*
|
|
5366
|
+
*
|
|
5280
5367
|
* @example
|
|
5281
5368
|
* ```typescript
|
|
5282
5369
|
* import { NaviosFactory } from '@navios/core'
|
|
5283
5370
|
* import { defineFastifyEnvironment } from '@navios/adapter-fastify'
|
|
5284
|
-
*
|
|
5371
|
+
*
|
|
5285
5372
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5286
5373
|
* adapter: defineFastifyEnvironment(),
|
|
5287
5374
|
* logger: ['log', 'error', 'warn'],
|
|
5288
5375
|
* })
|
|
5289
|
-
*
|
|
5376
|
+
*
|
|
5290
5377
|
* await app.init()
|
|
5291
5378
|
* await app.listen({ port: 3000 })
|
|
5292
5379
|
* ```
|
|
5293
5380
|
*/ var NaviosFactory = class {
|
|
5294
5381
|
/**
|
|
5295
5382
|
* Creates a new Navios application instance.
|
|
5296
|
-
*
|
|
5383
|
+
*
|
|
5297
5384
|
* This method sets up the dependency injection container, registers the HTTP adapter,
|
|
5298
5385
|
* configures logging, and initializes the application with the provided module.
|
|
5299
|
-
*
|
|
5386
|
+
*
|
|
5300
5387
|
* @param appModule - The root application module class decorated with @Module()
|
|
5301
5388
|
* @param options - Configuration options for the application
|
|
5302
5389
|
* @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
|
|
@@ -5306,20 +5393,20 @@ var NaviosApplication = class {
|
|
|
5306
5393
|
* - `false` to disable logging
|
|
5307
5394
|
* @param options.container - Optional custom dependency injection container (useful for testing)
|
|
5308
5395
|
* @returns A configured NaviosApplication instance ready to be initialized
|
|
5309
|
-
*
|
|
5396
|
+
*
|
|
5310
5397
|
* @example
|
|
5311
5398
|
* ```typescript
|
|
5312
5399
|
* // Basic setup with Fastify adapter
|
|
5313
5400
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5314
5401
|
* adapter: defineFastifyEnvironment(),
|
|
5315
5402
|
* })
|
|
5316
|
-
*
|
|
5403
|
+
*
|
|
5317
5404
|
* // With custom logger configuration
|
|
5318
5405
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5319
5406
|
* adapter: defineFastifyEnvironment(),
|
|
5320
5407
|
* logger: ['error', 'warn', 'log'],
|
|
5321
5408
|
* })
|
|
5322
|
-
*
|
|
5409
|
+
*
|
|
5323
5410
|
* // With custom container for testing
|
|
5324
5411
|
* const container = new Container()
|
|
5325
5412
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5343,11 +5430,14 @@ var NaviosApplication = class {
|
|
|
5343
5430
|
}
|
|
5344
5431
|
static async registerLoggerConfiguration(container, options) {
|
|
5345
5432
|
const { logger } = options;
|
|
5346
|
-
if (Array.isArray(logger) || isNil(logger))
|
|
5433
|
+
if (Array.isArray(logger) || isNil(logger)) {
|
|
5434
|
+
(await container.get(LoggerOutput))?.setup({ logLevels: logger });
|
|
5435
|
+
return;
|
|
5436
|
+
}
|
|
5347
5437
|
if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, InjectableType.Class, InjectableScope.Singleton);
|
|
5348
5438
|
}
|
|
5349
5439
|
};
|
|
5350
5440
|
|
|
5351
5441
|
//#endregion
|
|
5352
5442
|
export { envInt as $, loggerOptionsSchema as A, isObject as B, ConfigServiceOptionsSchema as C, _ConsoleLogger as D, _LoggerInstance as E, isConstructor as F, normalizePath as G, isString as H, isEmpty as I, filterLogLevels as J, stripEndSlash as K, isFunction as L, requestIdStore as M, runWithRequestId as N, Logger as O, addLeadingSlash as P, yellow as Q, isNil as R, provideConfig as S, _ConfigService as T, isSymbol as U, isPlainObject as V, isUndefined as W, LOG_LEVELS as X, isLogLevel as Y, clc as Z, ForbiddenException as _, _ReplyFactory as a, ConfigProviderOptions as b, _HttpAdapterFactory as c, _ModuleLoaderService as d, envString as et, _GuardRunnerService as f, InternalServerErrorException as g, NotFoundException as h, _StreamAdapterFactory as i, getRequestId as j, LoggerOutput as k, _EndpointAdapterFactory as l, UnauthorizedException as m, _NaviosApplication as n, _RequestFactory as o, ConflictException as p, isLogLevelEnabled as q, _XmlStreamAdapterFactory as r, _MultipartAdapterFactory as s, NaviosFactory as t, AttributeFactory as u, BadRequestException as v, ConfigServiceToken as w, EnvConfigProvider as x, HttpException as y, isNumber as z };
|
|
5353
|
-
//# sourceMappingURL=src-
|
|
5443
|
+
//# sourceMappingURL=src-DyvCDuKO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-DyvCDuKO.mjs","names":["LOG_LEVELS","LOG_LEVELS","isLogLevel","maybeLogLevel","includes","LOG_LEVELS","isLogLevel","filterLogLevels","parseableString","sanitizedString","replaceAll","toLowerCase","orEqual","logLevelIndex","indexOf","substring","Error","slice","includes","split","filter","LOG_LEVEL_VALUES","verbose","debug","log","warn","error","fatal","isLogLevelEnabled","targetLevel","logLevels","Array","isArray","length","includes","highestLogLevelValue","map","level","sort","a","b","targetLevelValue","AsyncLocalStorage","requestIdStore","runWithRequestId","requestId","fn","run","getRequestId","getStore","InjectionToken","z","LoggerOutput","create","loggerOptionsSchema","object","context","string","optional","Logger","inspect","Injectable","getRequestId","LoggerOutput","clc","isFunction","isLogLevelEnabled","isPlainObject","isString","isUndefined","yellow","DEFAULT_DEPTH","DEFAULT_LOG_LEVELS","dateTimeFormatter","Intl","DateTimeFormat","undefined","year","hour","minute","second","day","month","token","ConsoleLogger","options","context","originalContext","inspectOptions","getInspectOptions","lastTimestampAt","setup","contextOrOptions","opts","logLevels","colors","json","prefix","log","message","optionalParams","isLevelEnabled","messages","getContextAndMessagesToPrint","printMessages","error","stack","getContextAndStackAndMessagesToPrint","printStackTrace","warn","debug","verbose","fatal","setLogLevels","levels","setContext","resetContext","level","getCurrentRequestId","requestId","getTimestamp","format","Date","now","logLevel","writeStreamType","errorStack","resolvedRequestId","forEach","printAsJson","pidMessage","formatPid","process","pid","contextMessage","formatContext","timestampDiff","updateAndGetTimestampDiff","formattedLogLevel","toUpperCase","padStart","formattedMessage","formatMessage","write","logObject","timestamp","compact","JSON","stringify","stringifyReplacer","output","stringifyMessage","colorize","messageAsStr","Function","prototype","toString","call","isClass","startsWith","name","outputText","Object","keys","length","Array","isArray","color","getColorByLogLevel","stderr","includeTimestamp","result","formatTimestampDiff","formattedDiff","breakLength","Infinity","depth","sorted","showHidden","maxArrayLength","maxStringLength","key","value","Map","Set","Error","args","lastElement","isContext","slice","isStackFormat","isStack","test","magentaBright","red","cyanBright","bold","green","inject","Injectable","Logger","LoggerOutput","token","LoggerInstance","config","context","localInstance","error","message","optionalParams","length","undefined","concat","log","console","warn","debug","verbose","fatal","NaviosError","inject","Injectable","InjectionToken","z","Logger","ConfigServiceOptionsSchema","record","string","unknown","ConfigServiceToken","create","Symbol","for","token","ConfigService","config","logger","context","name","getConfig","get","key","parts","String","split","value","part","undefined","error","debug","getOrDefault","defaultValue","getOrThrow","errorMessage","message","env","InjectionToken","z","ConfigServiceOptionsSchema","ConfigServiceToken","ConfigProviderOptions","object","load","function","output","provideConfig","options","factory","EnvConfigProvider","bound","HttpException","statusCode","response","error","HttpException","BadRequestException","message","HttpException","ForbiddenException","message","HttpException","InternalServerErrorException","message","error","HttpException","NotFoundException","response","error","HttpException","UnauthorizedException","message","error","HttpException","ConflictException","message","error","inject","Injectable","HttpException","Logger","GuardRunnerService","logger","context","name","runGuards","allGuards","executionContext","canActivate","guard","Array","from","reverse","guardInstance","get","Error","error","getReply","status","statusCode","send","response","message","makeContext","moduleMetadata","controllerMetadata","endpoint","guards","Set","endpointGuards","controllerGuards","moduleGuards","size","add","Container","inject","Injectable","Logger","extractModuleMetadata","ModuleLoaderService","logger","context","name","container","modulesMetadata","Map","loadedModules","initialized","loadModules","appModule","traverseModules","extendModules","extensions","Error","extension","module","controllers","moduleName","registerControllers","has","existing","get","controller","add","debug","length","metadata","Set","imports","guards","customAttributes","set","parentMetadata","mergeMetadata","loadingPromises","Array","from","map","importedModule","Promise","all","instance","onModuleInit","error","guard","key","value","getAllModules","dispose","clear","getControllerMetadata","getEndpointMetadata","getModuleMetadata","hasControllerMetadata","hasModuleMetadata","AttributeFactory","createAttribute","token","schema","res","value","target","context","kind","Error","isController","isModule","metadata","validatedValue","safeParse","success","toString","error","customAttributes","set","data","get","attribute","getAll","values","Array","from","entries","filter","key","map","length","getLast","i","has","Injectable","NaviosEnvironment","httpTokens","Map","setupHttpEnvironment","tokens","getHttpToken","token","get","hasHttpSetup","size","Factory","inject","NaviosEnvironment","EndpointAdapterToken","token","EndpointAdapterFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","NaviosEnvironment","HttpAdapterToken","token","HttpAdapterFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","NaviosEnvironment","MultipartAdapterToken","token","MultipartAdapterFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","InjectableScope","NaviosEnvironment","Request","token","scope","RequestFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","InjectableScope","NaviosEnvironment","Reply","token","scope","Request","ReplyFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","NaviosEnvironment","StreamAdapterToken","token","StreamAdapterFactory","environment","create","ctx","service","getHttpToken","Error","Factory","inject","NaviosEnvironment","XmlStreamAdapterToken","token","XmlStreamAdapterFactory","environment","create","ctx","service","getHttpToken","Error","Container","inject","Injectable","HttpAdapterToken","Logger","NaviosEnvironment","ModuleLoaderService","NaviosApplication","environment","moduleLoader","httpApplication","logger","context","name","container","appModule","options","adapter","plugins","isInitialized","setup","hasHttpSetup","get","getContainer","usePlugin","definition","push","init","Error","loadModules","setupHttpServer","initPlugins","initModules","ready","debug","modules","getAllModules","onModulesInit","length","server","getServer","globalPrefix","getGlobalPrefix","plugin","register","enableCors","enableMultipart","setGlobalPrefix","prefix","listen","dispose","close","Container","InjectableScope","InjectableType","isNil","LoggerOutput","NaviosApplication","NaviosEnvironment","NaviosFactory","create","appModule","options","adapter","container","registerLoggerConfiguration","adapters","Array","isArray","registerEnvironment","app","get","setup","environment","naviosEnvironment","httpTokens","setupHttpEnvironment","logger","loggerInstance","logLevels","getServiceLocator","getManager","storeCreatedHolder","toString","Class","Singleton"],"sources":["../src/config/utils/helpers.mts","../src/logger/utils/cli-colors.util.mts","../src/logger/log-levels.mts","../src/logger/utils/is-log-level.util.mts","../src/logger/utils/filter-log-levelts.util.mts","../src/logger/utils/is-log-level-enabled.mts","../src/logger/utils/shared.utils.mts","../src/stores/request-id.store.mts","../src/logger/logger.tokens.mts","../src/logger/console-logger.service.mts","../src/logger/logger.service.mts","../src/config/config.service.mts","../src/config/config.provider.mts","../src/exceptions/http.exception.mts","../src/exceptions/bad-request.exception.mts","../src/exceptions/forbidden.exception.mts","../src/exceptions/internal-server-error.exception.mts","../src/exceptions/not-found.exception.mts","../src/exceptions/unauthorized.exception.mts","../src/exceptions/conflict.exception.mts","../src/services/guard-runner.service.mts","../src/services/module-loader.service.mts","../src/attribute.factory.mts","../src/navios.environment.mts","../src/factories/endpoint-adapter.factory.mts","../src/factories/http-adapter.factory.mts","../src/factories/multipart-adapter.factory.mts","../src/factories/request.factory.mts","../src/factories/reply.factory.mts","../src/factories/stream-adapter.factory.mts","../src/factories/xml-stream-adapter.factory.mts","../src/navios.application.mts","../src/navios.factory.mts"],"sourcesContent":["import { env } from 'node:process'\n\nexport function envInt(\n key: keyof NodeJS.ProcessEnv,\n defaultValue: number,\n): number {\n const envKey = env[key] || process.env[key]\n\n return envKey ? parseInt(envKey as string, 10) : defaultValue\n}\n\nexport function envString<\n DefaultValue extends string | undefined,\n Ensured = DefaultValue extends string ? true : false,\n>(\n key: keyof NodeJS.ProcessEnv,\n defaultValue?: DefaultValue,\n): Ensured extends true ? string : string | undefined {\n return (env[key] ||\n process.env[key] ||\n defaultValue ||\n undefined) as Ensured extends true ? string : string | undefined\n}\n","type ColorTextFn = (text: string) => string\n\nconst isColorAllowed = () => !process.env.NO_COLOR\nconst colorIfAllowed = (colorFn: ColorTextFn) => (text: string) =>\n isColorAllowed() ? colorFn(text) : text\n\nexport const clc = {\n bold: colorIfAllowed((text: string) => `\\x1B[1m${text}\\x1B[0m`),\n green: colorIfAllowed((text: string) => `\\x1B[32m${text}\\x1B[39m`),\n yellow: colorIfAllowed((text: string) => `\\x1B[33m${text}\\x1B[39m`),\n red: colorIfAllowed((text: string) => `\\x1B[31m${text}\\x1B[39m`),\n magentaBright: colorIfAllowed((text: string) => `\\x1B[95m${text}\\x1B[39m`),\n cyanBright: colorIfAllowed((text: string) => `\\x1B[96m${text}\\x1B[39m`),\n}\nexport const yellow = colorIfAllowed(\n (text: string) => `\\x1B[38;5;3m${text}\\x1B[39m`,\n)\n","/**\n * Available log levels in order of severity (lowest to highest).\n */\nexport const LOG_LEVELS = [\n 'verbose',\n 'debug',\n 'log',\n 'warn',\n 'error',\n 'fatal',\n] as const satisfies string[]\n\n/**\n * Log level type.\n * \n * Represents the severity level of a log message.\n * Levels are: 'verbose', 'debug', 'log', 'warn', 'error', 'fatal'\n * \n * @publicApi\n */\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n","import type { LogLevel } from '../log-levels.mjs'\n\nimport { LOG_LEVELS } from '../log-levels.mjs'\n\n/**\n * @publicApi\n */\nexport function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel {\n return LOG_LEVELS.includes(maybeLogLevel)\n}\n","import type { LogLevel } from '../log-levels.mjs'\n\nimport { LOG_LEVELS } from '../log-levels.mjs'\nimport { isLogLevel } from './is-log-level.util.mjs'\n\n/**\n * @publicApi\n */\nexport function filterLogLevels(parseableString = ''): LogLevel[] {\n const sanitizedString = parseableString.replaceAll(' ', '').toLowerCase()\n\n if (sanitizedString[0] === '>') {\n const orEqual = sanitizedString[1] === '='\n\n const logLevelIndex = (LOG_LEVELS as string[]).indexOf(\n sanitizedString.substring(orEqual ? 2 : 1),\n )\n\n if (logLevelIndex === -1) {\n throw new Error(`parse error (unknown log level): ${sanitizedString}`)\n }\n\n return LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1)\n } else if (sanitizedString.includes(',')) {\n return sanitizedString.split(',').filter(isLogLevel)\n }\n\n return isLogLevel(sanitizedString) ? [sanitizedString] : LOG_LEVELS\n}\n","import type { LogLevel } from '../log-levels.mjs'\n\nconst LOG_LEVEL_VALUES: Record<LogLevel, number> = {\n verbose: 0,\n debug: 1,\n log: 2,\n warn: 3,\n error: 4,\n fatal: 5,\n}\n\n/**\n * Checks if target level is enabled.\n * @param targetLevel target level\n * @param logLevels array of enabled log levels\n */\nexport function isLogLevelEnabled(\n targetLevel: LogLevel,\n logLevels: LogLevel[] | undefined,\n): boolean {\n if (!logLevels || (Array.isArray(logLevels) && logLevels?.length === 0)) {\n return false\n }\n if (logLevels.includes(targetLevel)) {\n return true\n }\n const highestLogLevelValue = logLevels\n .map((level) => LOG_LEVEL_VALUES[level])\n .sort((a, b) => b - a)?.[0]\n\n const targetLevelValue = LOG_LEVEL_VALUES[targetLevel]\n return targetLevelValue >= highestLogLevelValue\n}\n","export const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport const isPlainObject = (fn: any): fn is object => {\n if (!isObject(fn)) {\n return false\n }\n const proto = Object.getPrototypeOf(fn)\n if (proto === null) {\n return true\n }\n const ctor =\n Object.prototype.hasOwnProperty.call(proto, 'constructor') &&\n proto.constructor\n return (\n typeof ctor === 'function' &&\n ctor instanceof ctor &&\n Function.prototype.toString.call(ctor) ===\n Function.prototype.toString.call(Object)\n )\n}\n\nexport const addLeadingSlash = (path?: string): string =>\n path && typeof path === 'string'\n ? path.charAt(0) !== '/' && path.substring(0, 2) !== '{/'\n ? '/' + path\n : path\n : ''\n\nexport const normalizePath = (path?: string): string =>\n path\n ? path.startsWith('/')\n ? ('/' + path.replace(/\\/+$/, '')).replace(/\\/+/g, '/')\n : '/' + path.replace(/\\/+$/, '')\n : '/'\n\nexport const stripEndSlash = (path: string) =>\n path[path.length - 1] === '/' ? path.slice(0, path.length - 1) : path\n\nexport const isFunction = (val: any): val is Function =>\n typeof val === 'function'\nexport const isString = (val: any): val is string => typeof val === 'string'\nexport const isNumber = (val: any): val is number => typeof val === 'number'\nexport const isConstructor = (val: any): boolean => val === 'constructor'\nexport const isNil = (val: any): val is null | undefined =>\n isUndefined(val) || val === null\nexport const isEmpty = (array: any): boolean => !(array && array.length > 0)\nexport const isSymbol = (val: any): val is symbol => typeof val === 'symbol'\n","import { AsyncLocalStorage } from 'node:async_hooks'\n\n/**\n * AsyncLocalStorage store for the current request ID.\n *\n * This allows logging and other services to access the current request ID\n * without explicitly passing it through the call stack.\n *\n * @example\n * ```typescript\n * import { requestIdStore, runWithRequestId, getRequestId } from '@navios/core'\n *\n * // Run code with a request ID in context\n * runWithRequestId('req-123', () => {\n * // Inside this callback, getRequestId() returns 'req-123'\n * logger.log('Processing request') // Will include request ID if logger is configured\n * })\n *\n * // Get current request ID (returns undefined if not in a request context)\n * const currentId = getRequestId()\n * ```\n */\nexport const requestIdStore = new AsyncLocalStorage<string>()\n\n/**\n * Runs a function with a request ID in the async local storage context.\n *\n * @param requestId - The request ID to set for this context\n * @param fn - The function to run within this context\n * @returns The return value of the function\n */\nexport function runWithRequestId<R>(requestId: string, fn: () => R): R {\n return requestIdStore.run(requestId, fn)\n}\n\n/**\n * Gets the current request ID from the async local storage context.\n *\n * @returns The current request ID, or undefined if not in a request context\n */\nexport function getRequestId(): string | undefined {\n return requestIdStore.getStore()\n}\n","import { InjectionToken } from '@navios/di'\n\nimport z from 'zod/v4'\n\nimport type { LoggerService } from './logger-service.interface.mjs'\nimport type { LoggerInstance } from './logger.service.mjs'\n\n/**\n * Injection token for the logger output service.\n * \n * This token is used to provide a custom logger implementation.\n * By default, it's bound to ConsoleLogger.\n */\nexport const LoggerOutput = InjectionToken.create<LoggerService>('LoggerOutput')\n\n/**\n * Schema for logger options.\n */\nexport const loggerOptionsSchema = z\n .object({\n context: z.string().optional(),\n })\n .optional()\n\n/**\n * Options for creating a logger instance.\n */\nexport type LoggerOptions = z.infer<typeof loggerOptionsSchema>\n\n/**\n * Injection token for the Logger service.\n * \n * Use this token to inject a contextualized logger instance.\n * \n * @example\n * ```typescript\n * const logger = inject(Logger, { context: 'MyService' })\n * logger.log('Hello world') // Logs with context: [MyService]\n * ```\n */\nexport const Logger = InjectionToken.create<\n LoggerInstance,\n typeof loggerOptionsSchema\n>('Logger', loggerOptionsSchema)\n","import type { InspectOptions } from 'util'\n\nimport { inspect } from 'util'\n\nimport { Injectable } from '@navios/di'\n\nimport type { LogLevel } from './log-levels.mjs'\nimport type { LoggerService } from './logger-service.interface.mjs'\n\nimport { getRequestId } from '../stores/request-id.store.mjs'\nimport { LoggerOutput } from './logger.tokens.mjs'\nimport {\n clc,\n isFunction,\n isLogLevelEnabled,\n isPlainObject,\n isString,\n isUndefined,\n yellow,\n} from './utils/index.mjs'\n\nconst DEFAULT_DEPTH = 5\n\n/**\n * @publicApi\n */\nexport interface ConsoleLoggerOptions {\n /**\n * Enabled log levels.\n */\n logLevels?: LogLevel[]\n /**\n * If enabled, will print timestamp (time difference) between current and previous log message.\n * Note: This option is not used when `json` is enabled.\n */\n timestamp?: boolean\n /**\n * A prefix to be used for each log message.\n * Note: This option is not used when `json` is enabled.\n */\n prefix?: string\n /**\n * If enabled, will add a request ID to the log message.\n */\n requestId?: boolean\n /**\n * If enabled, will print the log message in JSON format.\n */\n json?: boolean\n /**\n * If enabled, will print the log message in color.\n * Default true if json is disabled, false otherwise\n */\n colors?: boolean\n /**\n * The context of the logger.\n */\n context?: string\n /**\n * If enabled, will print the log message in a single line, even if it is an object with multiple properties.\n * If set to a number, the most n inner elements are united on a single line as long as all properties fit into breakLength. Short array elements are also grouped together.\n * Default true when `json` is enabled, false otherwise.\n */\n compact?: boolean | number\n /**\n * Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.\n * Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.\n * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.\n * @default 100\n */\n maxArrayLength?: number\n /**\n * Specifies the maximum number of characters to include when formatting.\n * Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.\n * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.\n * @default 10000.\n */\n maxStringLength?: number\n /**\n * If enabled, will sort keys while formatting objects.\n * Can also be a custom sorting function.\n * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.\n * @default false\n */\n sorted?: boolean | ((a: string, b: string) => number)\n /**\n * Specifies the number of times to recurse while formatting object. T\n * This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.\n * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.\n * @default 5\n */\n depth?: number\n /**\n * If true, object's non-enumerable symbols and properties are included in the formatted result.\n * WeakMap and WeakSet entries are also included as well as user defined prototype properties\n * @default false\n */\n showHidden?: boolean\n /**\n * The length at which input values are split across multiple lines. Set to Infinity to format the input as a single line (in combination with \"compact\" set to true).\n * Default Infinity when \"compact\" is true, 80 otherwise.\n * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.\n */\n breakLength?: number\n}\n\nconst DEFAULT_LOG_LEVELS: LogLevel[] = [\n 'log',\n 'error',\n 'warn',\n 'debug',\n 'verbose',\n 'fatal',\n]\n\nconst dateTimeFormatter = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n day: '2-digit',\n month: '2-digit',\n})\n\n/**\n * @publicApi\n */\n@Injectable({\n token: LoggerOutput,\n})\nexport class ConsoleLogger implements LoggerService {\n /**\n * The options of the logger.\n */\n protected options: ConsoleLoggerOptions = {}\n /**\n * The context of the logger (can be set manually or automatically inferred).\n */\n protected context?: string\n /**\n * The original context of the logger (set in the constructor).\n */\n protected originalContext?: string\n /**\n * The options used for the \"inspect\" method.\n */\n protected inspectOptions: InspectOptions = this.getInspectOptions()\n /**\n * The last timestamp at which the log message was printed.\n */\n protected lastTimestampAt?: number\n\n setup(): void\n setup(context: string): void\n setup(options: ConsoleLoggerOptions): void\n setup(context: string, options: ConsoleLoggerOptions): void\n setup(\n contextOrOptions?: string | ConsoleLoggerOptions,\n options?: ConsoleLoggerOptions,\n ) {\n // eslint-disable-next-line prefer-const\n let [context, opts] = isString(contextOrOptions)\n ? [contextOrOptions, options]\n : options\n ? [undefined, options]\n : [contextOrOptions?.context, contextOrOptions]\n\n opts = opts ?? {}\n opts.logLevels ??= DEFAULT_LOG_LEVELS\n opts.colors ??= opts.colors ?? (opts.json ? false : true)\n opts.prefix ??= 'Navios'\n\n this.options = opts\n this.inspectOptions = this.getInspectOptions()\n\n if (context) {\n this.context = context\n this.originalContext = context\n }\n }\n\n /**\n * Write a 'log' level log, if the configured level allows for it.\n * Prints to `stdout` with newline.\n */\n log(message: any, context?: string): void\n log(message: any, ...optionalParams: [...any, string?]): void\n log(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('log')) {\n return\n }\n const { messages, context } = this.getContextAndMessagesToPrint([\n message,\n ...optionalParams,\n ])\n this.printMessages(messages, context, 'log')\n }\n\n /**\n * Write an 'error' level log, if the configured level allows for it.\n * Prints to `stderr` with newline.\n */\n error(message: any, stackOrContext?: string): void\n error(message: any, stack?: string, context?: string): void\n error(message: any, ...optionalParams: [...any, string?, string?]): void\n error(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('error')) {\n return\n }\n const { messages, context, stack } =\n this.getContextAndStackAndMessagesToPrint([message, ...optionalParams])\n\n this.printMessages(messages, context, 'error', undefined, 'stderr', stack)\n this.printStackTrace(stack!)\n }\n\n /**\n * Write a 'warn' level log, if the configured level allows for it.\n * Prints to `stdout` with newline.\n */\n warn(message: any, context?: string): void\n warn(message: any, ...optionalParams: [...any, string?]): void\n warn(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('warn')) {\n return\n }\n const { messages, context } = this.getContextAndMessagesToPrint([\n message,\n ...optionalParams,\n ])\n this.printMessages(messages, context, 'warn')\n }\n\n /**\n * Write a 'debug' level log, if the configured level allows for it.\n * Prints to `stdout` with newline.\n */\n debug(message: any, context?: string): void\n debug(message: any, ...optionalParams: [...any, string?]): void\n debug(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('debug')) {\n return\n }\n const { messages, context } = this.getContextAndMessagesToPrint([\n message,\n ...optionalParams,\n ])\n this.printMessages(messages, context, 'debug')\n }\n\n /**\n * Write a 'verbose' level log, if the configured level allows for it.\n * Prints to `stdout` with newline.\n */\n verbose(message: any, context?: string): void\n verbose(message: any, ...optionalParams: [...any, string?]): void\n verbose(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('verbose')) {\n return\n }\n const { messages, context } = this.getContextAndMessagesToPrint([\n message,\n ...optionalParams,\n ])\n this.printMessages(messages, context, 'verbose')\n }\n\n /**\n * Write a 'fatal' level log, if the configured level allows for it.\n * Prints to `stdout` with newline.\n */\n fatal(message: any, context?: string): void\n fatal(message: any, ...optionalParams: [...any, string?]): void\n fatal(message: any, ...optionalParams: any[]) {\n if (!this.isLevelEnabled('fatal')) {\n return\n }\n const { messages, context } = this.getContextAndMessagesToPrint([\n message,\n ...optionalParams,\n ])\n this.printMessages(messages, context, 'fatal')\n }\n\n /**\n * Set log levels\n * @param levels log levels\n */\n setLogLevels(levels: LogLevel[]) {\n if (!this.options) {\n this.options = {}\n }\n this.options.logLevels = levels\n }\n\n /**\n * Set logger context\n * @param context context\n */\n setContext(context: string) {\n this.context = context\n }\n\n /**\n * Resets the logger context to the value that was passed in the constructor.\n */\n resetContext() {\n this.context = this.originalContext\n }\n\n isLevelEnabled(level: LogLevel): boolean {\n const logLevels = this.options?.logLevels\n return isLogLevelEnabled(level, logLevels)\n }\n\n /**\n * Gets the current request ID from the AsyncLocalStorage store.\n * Only returns a value if the requestId option is enabled.\n */\n protected getCurrentRequestId(): string | undefined {\n if (!this.options.requestId) {\n return undefined\n }\n return getRequestId()\n }\n\n protected getTimestamp(): string {\n return dateTimeFormatter.format(Date.now())\n }\n\n protected printMessages(\n messages: unknown[],\n context = '',\n logLevel: LogLevel = 'log',\n requestId?: string,\n writeStreamType?: 'stdout' | 'stderr',\n errorStack?: unknown,\n ) {\n const resolvedRequestId = requestId ?? this.getCurrentRequestId()\n messages.forEach((message) => {\n if (this.options.json) {\n this.printAsJson(message, {\n context,\n logLevel,\n writeStreamType,\n errorStack,\n requestId: resolvedRequestId,\n })\n return\n }\n const pidMessage = this.formatPid(process.pid)\n const contextMessage = this.formatContext(context)\n const timestampDiff = this.updateAndGetTimestampDiff()\n const formattedLogLevel = logLevel.toUpperCase().padStart(7, ' ')\n const formattedMessage = this.formatMessage(\n logLevel,\n message,\n pidMessage,\n formattedLogLevel,\n contextMessage,\n timestampDiff,\n resolvedRequestId,\n )\n\n process[writeStreamType ?? 'stdout'].write(formattedMessage)\n })\n }\n\n protected printAsJson(\n message: unknown,\n options: {\n context: string\n logLevel: LogLevel\n writeStreamType?: 'stdout' | 'stderr'\n errorStack?: unknown\n requestId?: string\n },\n ) {\n type JsonLogObject = {\n level: LogLevel\n pid: number\n timestamp: number\n message: unknown\n context?: string\n stack?: unknown\n requestId?: string\n }\n\n const logObject: JsonLogObject = {\n level: options.logLevel,\n pid: process.pid,\n timestamp: Date.now(),\n message,\n }\n\n if (options.context) {\n logObject.context = options.context\n }\n\n if (options.errorStack) {\n logObject.stack = options.errorStack\n }\n if (this.options.requestId && options.requestId) {\n logObject.requestId = options.requestId\n }\n\n const formattedMessage =\n !this.options.colors && this.inspectOptions.compact === true\n ? JSON.stringify(logObject, this.stringifyReplacer)\n : inspect(logObject, this.inspectOptions)\n process[options.writeStreamType ?? 'stdout'].write(`${formattedMessage}\\n`)\n }\n\n protected formatPid(pid: number) {\n return `[${this.options.prefix}] ${pid} - `\n }\n\n protected formatContext(context: string): string {\n if (!context) {\n return ''\n }\n\n context = `[${context}] `\n return this.options.colors ? yellow(context) : context\n }\n\n protected formatMessage(\n logLevel: LogLevel,\n message: unknown,\n pidMessage: string,\n formattedLogLevel: string,\n contextMessage: string,\n timestampDiff: string,\n requestId?: string,\n ) {\n const output = this.stringifyMessage(message, logLevel)\n pidMessage = this.colorize(pidMessage, logLevel)\n formattedLogLevel = this.colorize(formattedLogLevel, logLevel)\n return `${pidMessage}${this.getRequestId(requestId)}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}\\n`\n }\n\n protected getRequestId(requestId?: string) {\n if (this.options.requestId && requestId) {\n return `(${this.colorize(requestId, 'log')}) `\n }\n return ''\n }\n\n protected stringifyMessage(message: unknown, logLevel: LogLevel): string {\n if (isFunction(message)) {\n const messageAsStr = Function.prototype.toString.call(message)\n const isClass = messageAsStr.startsWith('class ')\n if (isClass) {\n // If the message is a class, we will display the class name.\n return this.stringifyMessage(message.name, logLevel)\n }\n // If the message is a non-class function, call it and re-resolve its value.\n return this.stringifyMessage(message(), logLevel)\n }\n\n if (typeof message === 'string') {\n return this.colorize(message, logLevel)\n }\n\n const outputText = inspect(message, this.inspectOptions)\n if (isPlainObject(message)) {\n return `Object(${Object.keys(message).length}) ${outputText}`\n }\n if (Array.isArray(message)) {\n return `Array(${message.length}) ${outputText}`\n }\n return outputText\n }\n\n protected colorize(message: string, logLevel: LogLevel) {\n if (!this.options.colors || this.options.json) {\n return message\n }\n const color = this.getColorByLogLevel(logLevel)\n return color(message)\n }\n\n protected printStackTrace(stack: string) {\n if (!stack || this.options.json) {\n return\n }\n process.stderr.write(`${stack}\\n`)\n }\n\n protected updateAndGetTimestampDiff(): string {\n const includeTimestamp = this.lastTimestampAt && this.options?.timestamp\n const result = includeTimestamp\n ? this.formatTimestampDiff(Date.now() - this.lastTimestampAt!)\n : ''\n this.lastTimestampAt = Date.now()\n return result\n }\n\n protected formatTimestampDiff(timestampDiff: number) {\n const formattedDiff = ` +${timestampDiff}ms`\n return this.options.colors ? yellow(formattedDiff) : formattedDiff\n }\n\n protected getInspectOptions() {\n let breakLength = this.options.breakLength\n if (typeof breakLength === 'undefined') {\n breakLength = this.options.colors\n ? this.options.compact\n ? Infinity\n : undefined\n : this.options.compact === false\n ? undefined\n : Infinity // default breakLength to Infinity if inline is not set and colors is false\n }\n\n const inspectOptions: InspectOptions = {\n depth: this.options.depth ?? DEFAULT_DEPTH,\n sorted: this.options.sorted,\n showHidden: this.options.showHidden,\n compact: this.options.compact ?? (this.options.json ? true : false),\n colors: this.options.colors,\n breakLength,\n }\n\n if (this.options.maxArrayLength) {\n inspectOptions.maxArrayLength = this.options.maxArrayLength\n }\n if (this.options.maxStringLength) {\n inspectOptions.maxStringLength = this.options.maxStringLength\n }\n\n return inspectOptions\n }\n\n protected stringifyReplacer(key: string, value: unknown) {\n // Mimic util.inspect behavior for JSON logger with compact on and colors off\n if (typeof value === 'bigint') {\n return value.toString()\n }\n if (typeof value === 'symbol') {\n return value.toString()\n }\n\n if (\n value instanceof Map ||\n value instanceof Set ||\n value instanceof Error\n ) {\n return `${inspect(value, this.inspectOptions)}`\n }\n return value\n }\n\n private getContextAndMessagesToPrint(args: unknown[]) {\n if (args?.length <= 1) {\n return { messages: args, context: this.context }\n }\n const lastElement = args[args.length - 1]\n const isContext = isString(lastElement)\n if (!isContext) {\n return { messages: args, context: this.context }\n }\n return {\n context: lastElement,\n messages: args.slice(0, args.length - 1),\n }\n }\n\n private getContextAndStackAndMessagesToPrint(args: unknown[]) {\n if (args.length === 2) {\n return this.isStackFormat(args[1])\n ? {\n messages: [args[0]],\n stack: args[1] as string,\n context: this.context,\n }\n : {\n messages: [args[0]],\n context: args[1] as string,\n }\n }\n\n const { messages, context } = this.getContextAndMessagesToPrint(args)\n if (messages?.length <= 1) {\n return { messages, context }\n }\n const lastElement = messages[messages.length - 1]\n const isStack = isString(lastElement)\n // https://github.com/nestjs/nest/issues/11074#issuecomment-1421680060\n if (!isStack && !isUndefined(lastElement)) {\n return { messages, context }\n }\n return {\n stack: lastElement,\n messages: messages.slice(0, messages.length - 1),\n context,\n }\n }\n\n private isStackFormat(stack: unknown) {\n if (!isString(stack) && !isUndefined(stack)) {\n return false\n }\n\n return /^(.)+\\n\\s+at .+:\\d+:\\d+/.test(stack!)\n }\n\n private getColorByLogLevel(level: LogLevel) {\n switch (level) {\n case 'debug':\n return clc.magentaBright\n case 'warn':\n return clc.yellow\n case 'error':\n return clc.red\n case 'verbose':\n return clc.cyanBright\n case 'fatal':\n return clc.bold\n default:\n return clc.green\n }\n }\n}\n","import { inject, Injectable } from '@navios/di'\n\nimport type { LoggerService } from './logger-service.interface.mjs'\nimport type { LoggerOptions } from './logger.tokens.mjs'\n\nimport { Logger, LoggerOutput } from './logger.tokens.mjs'\n\n/**\n * Logger service instance that can be injected into services and controllers.\n *\n * Provides contextualized logging with automatic context injection.\n * The context is set when the logger is injected using the `inject` function.\n *\n * @example\n * ```typescript\n * @Injectable()\n * export class UserService {\n * private logger = inject(Logger, { context: UserService.name })\n *\n * async findUser(id: string) {\n * this.logger.log(`Finding user ${id}`)\n * // Logs with context: [UserService]\n * }\n * }\n * ```\n */\n@Injectable({\n token: Logger,\n})\nexport class LoggerInstance implements LoggerService {\n protected localInstance = inject(LoggerOutput)\n\n protected context?: string\n\n constructor(config: LoggerOptions = {}) {\n this.context = config.context\n }\n\n /**\n * Write an 'error' level log.\n */\n error(message: any, stack?: string, context?: string): void\n error(message: any, ...optionalParams: [...any, string?, string?]): void\n error(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? (optionalParams.length ? optionalParams : [undefined]).concat(\n this.context,\n )\n : optionalParams\n\n this.localInstance?.error(message, ...optionalParams)\n }\n\n /**\n * Write a 'log' level log.\n */\n log(message: any, context?: string): void\n log(message: any, ...optionalParams: [...any, string?]): void\n log(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? optionalParams.concat(this.context)\n : optionalParams\n console.log('log', message, optionalParams)\n console.log('localInstance', this.localInstance)\n this.localInstance?.log(message, ...optionalParams)\n }\n\n /**\n * Write a 'warn' level log.\n */\n warn(message: any, context?: string): void\n warn(message: any, ...optionalParams: [...any, string?]): void\n warn(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? optionalParams.concat(this.context)\n : optionalParams\n this.localInstance?.warn(message, ...optionalParams)\n }\n\n /**\n * Write a 'debug' level log.\n */\n debug(message: any, context?: string): void\n debug(message: any, ...optionalParams: [...any, string?]): void\n debug(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? optionalParams.concat(this.context)\n : optionalParams\n this.localInstance?.debug?.(message, ...optionalParams)\n }\n\n /**\n * Write a 'verbose' level log.\n */\n verbose(message: any, context?: string): void\n verbose(message: any, ...optionalParams: [...any, string?]): void\n verbose(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? optionalParams.concat(this.context)\n : optionalParams\n this.localInstance?.verbose?.(message, ...optionalParams)\n }\n\n /**\n * Write a 'fatal' level log.\n */\n fatal(message: any, context?: string): void\n fatal(message: any, ...optionalParams: [...any, string?]): void\n fatal(message: any, ...optionalParams: any[]) {\n optionalParams = this.context\n ? optionalParams.concat(this.context)\n : optionalParams\n this.localInstance?.fatal?.(message, ...optionalParams)\n }\n}\n","import { NaviosError } from '@navios/builder'\nimport { inject, Injectable, InjectionToken } from '@navios/di'\n\nimport { z } from 'zod/v4'\n\nimport type { ConfigServiceInterface as IConfigService } from './config-service.interface.mjs'\nimport type { Path, PathValue } from './types.mjs'\n\nimport { Logger } from '../logger/index.mjs'\n\n/**\n * Schema for validating configuration service options.\n */\nexport const ConfigServiceOptionsSchema = z.record(z.string(), z.unknown())\n/**\n * Type for configuration service options.\n */\nexport type ConfigServiceOptions = z.infer<typeof ConfigServiceOptionsSchema>\n\n/**\n * Injection token for ConfigService.\n */\nexport const ConfigServiceToken = InjectionToken.create<\n IConfigService,\n typeof ConfigServiceOptionsSchema\n>(Symbol.for('ConfigService'), ConfigServiceOptionsSchema)\n\n/**\n * Service for managing application configuration with type-safe access.\n *\n * Provides methods to access configuration values using dot-notation paths\n * with full TypeScript type inference.\n *\n * @typeParam Config - The configuration object type\n *\n * @example\n * ```typescript\n * interface AppConfig {\n * database: {\n * host: string\n * port: number\n * }\n * api: {\n * timeout: number\n * }\n * }\n *\n * @Injectable()\n * export class DatabaseService {\n * private config = inject(MyConfigService)\n *\n * connect() {\n * const host = this.config.getOrThrow('database.host')\n * const port = this.config.getOrDefault('database.port', 5432)\n * // host is typed as string, port is typed as number\n * }\n * }\n * ```\n */\n@Injectable({\n token: ConfigServiceToken,\n})\nexport class ConfigService<\n Config extends ConfigServiceOptions = Record<string, unknown>,\n> implements IConfigService<Config> {\n private readonly logger = inject(Logger, {\n context: ConfigService.name,\n })\n\n /**\n * Creates a new ConfigService instance.\n *\n * @param config - The configuration object\n */\n constructor(private config: Config = {} as Config) {}\n\n /**\n * Gets the entire configuration object.\n *\n * @returns The complete configuration object\n */\n getConfig(): Config {\n return this.config\n }\n\n /**\n * Gets a configuration value by key path.\n *\n * Returns `null` if the key is not found or if any part of the path is invalid.\n *\n * @param key - Dot-separated path to the configuration value (e.g., 'database.host')\n * @returns The configuration value or `null` if not found\n *\n * @example\n * ```typescript\n * const host = config.get('database.host') // string | null\n * const port = config.get('database.port') // number | null\n * ```\n */\n get<Key extends Path<Config>>(key: Key): PathValue<Config, Key> | null {\n try {\n const parts = String(key).split('.')\n let value: any = this.config\n\n for (const part of parts) {\n if (\n value === null ||\n value === undefined ||\n typeof value !== 'object'\n ) {\n return null\n }\n value = value[part]\n }\n\n return (value as PathValue<Config, Key>) ?? null\n } catch (error) {\n this.logger.debug?.(\n `Failed to get config value for key ${String(key)}`,\n error,\n )\n return null\n }\n }\n\n /**\n * Gets a configuration value by key path, or returns a default value if not found.\n *\n * @param key - Dot-separated path to the configuration value\n * @param defaultValue - Default value to return if the key is not found\n * @returns The configuration value or the default value\n *\n * @example\n * ```typescript\n * const port = config.getOrDefault('database.port', 5432) // number\n * ```\n */\n getOrDefault<Key extends Path<Config>>(\n key: Key,\n defaultValue: PathValue<Config, Key>,\n ): PathValue<Config, Key> {\n const value = this.get(key)\n return value !== null ? value : defaultValue\n }\n\n /**\n * Gets a configuration value by key path, or throws an error if not found.\n *\n * @param key - Dot-separated path to the configuration value\n * @param errorMessage - Optional custom error message\n * @returns The configuration value\n * @throws Error if the key is not found\n *\n * @example\n * ```typescript\n * const host = config.getOrThrow('database.host') // string (throws if not found)\n * const apiKey = config.getOrThrow('api.key', 'API key is required') // string\n * ```\n */\n getOrThrow<Key extends Path<Config>>(\n key: Key,\n errorMessage?: string,\n ): PathValue<Config, Key> {\n const value = this.get(key)\n\n if (value === null) {\n const message =\n errorMessage ||\n `Configuration value for key \"${String(key)}\" is not defined`\n this.logger.error(message)\n throw new NaviosError(message)\n }\n\n return value\n }\n}\n","import { env } from 'node:process'\n\nimport { FactoryInjectionToken, InjectionToken } from '@navios/di'\n\nimport { z } from 'zod/v4'\n\nimport type { ConfigServiceOptions } from './config.service.mjs'\n\nimport {\n ConfigService,\n ConfigServiceOptionsSchema,\n ConfigServiceToken,\n} from './config.service.mjs'\n\n/**\n * Schema for configuration provider options.\n */\nexport const ConfigProviderOptions = z.object({\n load: z.function({ output: ConfigServiceOptionsSchema }),\n})\n\n/**\n * Creates a factory injection token for ConfigService that loads configuration asynchronously.\n *\n * Use this when you need to load configuration from a file, database, or other async source.\n *\n * @param options - Configuration provider options\n * @param options.load - Async function that loads and returns the configuration object\n * @returns A factory injection token for ConfigService\n *\n * @example\n * ```typescript\n * const MyConfigService = provideConfig({\n * load: async () => {\n * const config = await loadConfigFromFile('config.json')\n * return config\n * },\n * })\n *\n * // Use in module setup\n * container.bind(ConfigServiceToken).toFactory(configProvider)\n * ```\n */\nexport function provideConfig<ConfigMap extends ConfigServiceOptions>(\n options: z.input<typeof ConfigProviderOptions>,\n): FactoryInjectionToken<\n ConfigService<ConfigMap>,\n typeof ConfigServiceOptionsSchema\n> {\n return InjectionToken.factory(ConfigServiceToken, async () => options.load())\n}\n\n/**\n * Pre-configured ConfigService provider that uses environment variables.\n *\n * Provides a ConfigService instance bound to `process.env`.\n *\n * @example\n * ```typescript\n * // Use environment variables as configuration\n * container.bind(ConfigServiceToken).toValue(EnvConfigProvider)\n * ```\n */\nexport const EnvConfigProvider = InjectionToken.bound<\n ConfigService<Record<string, string>>,\n typeof ConfigServiceOptionsSchema\n>(ConfigServiceToken, {\n ...env,\n})\n","/**\n * Base exception class for all HTTP exceptions in Navios.\n * \n * All HTTP exception classes extend this base class. When thrown from an endpoint handler,\n * Navios will automatically convert it to an appropriate HTTP response with the specified\n * status code and response body.\n * \n * @example\n * ```typescript\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * const user = await this.userService.findById(request.urlParams.userId)\n * if (!user) {\n * throw new HttpException(404, 'User not found')\n * }\n * return user\n * }\n * ```\n */\nexport class HttpException {\n /**\n * Creates a new HttpException instance.\n * \n * @param statusCode - HTTP status code (e.g., 400, 404, 500)\n * @param response - Response body (string or object)\n * @param error - Optional underlying error for logging/debugging\n */\n constructor(\n public readonly statusCode: number,\n public readonly response: string | object,\n public readonly error?: Error,\n ) {}\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 400 Bad Request HTTP error.\n * \n * Use this exception when the client's request is malformed or invalid.\n * \n * @example\n * ```typescript\n * @Endpoint(createUserEndpoint)\n * async createUser(request: EndpointParams<typeof createUserEndpoint>) {\n * if (!request.data.email) {\n * throw new BadRequestException('Email is required')\n * }\n * // ...\n * }\n * ```\n */\nexport class BadRequestException extends HttpException {\n /**\n * Creates a new BadRequestException.\n * \n * @param message - Error message or response object\n */\n constructor(message: string | object) {\n super(400, message)\n }\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 403 Forbidden HTTP error.\n * \n * Use this exception when the client is authenticated but does not have\n * permission to access the requested resource.\n * \n * @example\n * ```typescript\n * @Endpoint(deleteUserEndpoint)\n * @UseGuards(AuthGuard, RoleGuard)\n * async deleteUser(request: EndpointParams<typeof deleteUserEndpoint>) {\n * if (!this.userService.hasPermission(request.user, 'delete')) {\n * throw new ForbiddenException('Insufficient permissions')\n * }\n * // ...\n * }\n * ```\n */\nexport class ForbiddenException extends HttpException {\n /**\n * Creates a new ForbiddenException.\n * \n * @param message - Error message\n */\n constructor(message: string) {\n super(403, message)\n }\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 500 Internal Server Error HTTP error.\n * \n * Use this exception when an unexpected error occurs on the server.\n * Generally, you should let unhandled errors bubble up rather than catching\n * and rethrowing as InternalServerErrorException, as Navios will handle them appropriately.\n * \n * @example\n * ```typescript\n * @Endpoint(processPaymentEndpoint)\n * async processPayment(request: EndpointParams<typeof processPaymentEndpoint>) {\n * try {\n * return await this.paymentService.process(request.data)\n * } catch (error) {\n * this.logger.error('Payment processing failed', error)\n * throw new InternalServerErrorException('Payment processing failed', error)\n * }\n * }\n * ```\n */\nexport class InternalServerErrorException extends HttpException {\n /**\n * Creates a new InternalServerErrorException.\n * \n * @param message - Error message or response object\n * @param error - Optional underlying error for logging\n */\n constructor(message: string | object, error?: Error) {\n super(500, message, error)\n }\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 404 Not Found HTTP error.\n * \n * Use this exception when the requested resource does not exist.\n * \n * @example\n * ```typescript\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * const user = await this.userService.findById(request.urlParams.userId)\n * if (!user) {\n * throw new NotFoundException('User not found')\n * }\n * return user\n * }\n * ```\n */\nexport class NotFoundException extends HttpException {\n /**\n * Creates a new NotFoundException.\n * \n * @param response - Error message or response object\n * @param error - Optional underlying error for logging\n */\n constructor(\n public readonly response: string | object,\n public readonly error?: Error,\n ) {\n super(404, response, error)\n }\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 401 Unauthorized HTTP error.\n * \n * Use this exception when the client is not authenticated or authentication failed.\n * \n * @example\n * ```typescript\n * @Endpoint(getUserEndpoint)\n * @UseGuards(AuthGuard)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * if (!request.headers.authorization) {\n * throw new UnauthorizedException('Authentication required')\n * }\n * // ...\n * }\n * ```\n */\nexport class UnauthorizedException extends HttpException {\n /**\n * Creates a new UnauthorizedException.\n * \n * @param message - Error message or response object\n * @param error - Optional underlying error for logging\n */\n constructor(message: string | object, error?: Error) {\n super(401, message, error)\n }\n}\n","import { HttpException } from './http.exception.mjs'\n\n/**\n * Exception that represents a 409 Conflict HTTP error.\n * \n * Use this exception when the request conflicts with the current state of the resource\n * (e.g., trying to create a resource that already exists).\n * \n * @example\n * ```typescript\n * @Endpoint(createUserEndpoint)\n * async createUser(request: EndpointParams<typeof createUserEndpoint>) {\n * const existing = await this.userService.findByEmail(request.data.email)\n * if (existing) {\n * throw new ConflictException('User with this email already exists')\n * }\n * // ...\n * }\n * ```\n */\nexport class ConflictException extends HttpException {\n /**\n * Creates a new ConflictException.\n * \n * @param message - Error message or response object\n * @param error - Optional underlying error for logging\n */\n constructor(message: string | object, error?: Error) {\n super(409, message, error)\n }\n}\n","import type { ClassTypeWithInstance, ScopedContainer } from '@navios/di'\n\nimport { inject, Injectable, InjectionToken } from '@navios/di'\n\nimport type {\n AbstractExecutionContext,\n CanActivate,\n} from '../interfaces/index.mjs'\nimport type {\n ControllerMetadata,\n HandlerMetadata,\n ModuleMetadata,\n} from '../metadata/index.mjs'\n\nimport { HttpException } from '../exceptions/index.mjs'\nimport { Logger } from '../logger/index.mjs'\n\n@Injectable()\nexport class GuardRunnerService {\n private readonly logger = inject(Logger, {\n context: GuardRunnerService.name,\n })\n async runGuards(\n allGuards: Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >,\n executionContext: AbstractExecutionContext,\n context: ScopedContainer,\n ) {\n let canActivate = true\n for (const guard of Array.from(allGuards).reverse()) {\n const guardInstance = await context.get(\n guard as InjectionToken<CanActivate, undefined>,\n )\n if (!guardInstance.canActivate) {\n throw new Error(\n `[Navios] Guard ${guard.name as string} does not implement canActivate()`,\n )\n }\n try {\n canActivate = await guardInstance.canActivate(executionContext)\n if (!canActivate) {\n break\n }\n } catch (error) {\n if (error instanceof HttpException) {\n executionContext\n .getReply()\n .status(error.statusCode)\n .send(error.response)\n return false\n } else {\n this.logger.error('Error running guard', error)\n executionContext.getReply().status(500).send({\n message: 'Internal server error',\n })\n return false\n }\n }\n }\n if (!canActivate) {\n executionContext.getReply().status(403).send({\n message: 'Forbidden',\n })\n return false\n }\n return canActivate\n }\n\n makeContext(\n moduleMetadata: ModuleMetadata,\n controllerMetadata: ControllerMetadata,\n endpoint: HandlerMetadata,\n ): Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n > {\n const guards = new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >()\n const endpointGuards = endpoint.guards\n const controllerGuards = controllerMetadata.guards\n const moduleGuards = moduleMetadata.guards\n if (endpointGuards.size > 0) {\n for (const guard of endpointGuards) {\n guards.add(guard)\n }\n }\n if (controllerGuards.size > 0) {\n for (const guard of controllerGuards) {\n guards.add(guard)\n }\n }\n if (moduleGuards.size > 0) {\n for (const guard of moduleGuards) {\n guards.add(guard)\n }\n }\n return guards\n }\n}\n","import type { ClassType, ClassTypeWithInstance } from '@navios/di'\n\nimport { Container, inject, Injectable } from '@navios/di'\n\nimport type { NaviosModule } from '../interfaces/index.mjs'\nimport type { ModuleMetadata } from '../metadata/index.mjs'\n\nimport { Logger } from '../logger/index.mjs'\nimport { extractModuleMetadata } from '../metadata/index.mjs'\n\n/**\n * Extension definition for dynamically adding to the module tree.\n * Used by plugins to inject controllers or entire modules.\n */\nexport interface ModuleExtension {\n /**\n * Module class to add. If provided, the module and all its\n * controllers/imports will be processed.\n */\n module?: ClassTypeWithInstance<NaviosModule>\n\n /**\n * Controllers to add directly without a wrapper module.\n * Will be registered under a synthetic module named after the plugin.\n */\n controllers?: ClassType[]\n\n /**\n * Name for the synthetic module when using controllers directly.\n * Required if `controllers` is provided without `module`.\n */\n moduleName?: string\n}\n\n@Injectable()\nexport class ModuleLoaderService {\n private logger = inject(Logger, {\n context: ModuleLoaderService.name,\n })\n protected container = inject(Container)\n private modulesMetadata: Map<string, ModuleMetadata> = new Map()\n private loadedModules: Map<string, any> = new Map()\n private initialized = false\n\n async loadModules(appModule: ClassTypeWithInstance<NaviosModule>) {\n if (this.initialized) {\n return\n }\n await this.traverseModules(appModule)\n this.initialized = true\n }\n\n /**\n * Extends the module tree with additional modules or controllers.\n *\n * This method is designed to be called by plugins during registration,\n * which happens after initial module loading but before route registration.\n *\n * @param extensions - Array of module extensions to add\n * @throws Error if not initialized (loadModules must be called first)\n *\n * @example\n * ```typescript\n * // In plugin registration\n * const moduleLoader = await context.container.get(ModuleLoaderService)\n * await moduleLoader.extendModules([{\n * controllers: [OpenApiJsonController, OpenApiYamlController],\n * moduleName: 'OpenApiBunModule',\n * }])\n * ```\n */\n async extendModules(extensions: ModuleExtension[]): Promise<void> {\n if (!this.initialized) {\n throw new Error(\n 'ModuleLoaderService must be initialized before extending. Call loadModules() first.',\n )\n }\n\n for (const extension of extensions) {\n if (extension.module) {\n // Process a full module with its imports and controllers\n await this.traverseModules(extension.module)\n } else if (extension.controllers && extension.moduleName) {\n // Create synthetic module metadata for loose controllers\n await this.registerControllers(\n extension.controllers,\n extension.moduleName,\n )\n } else if (extension.controllers) {\n throw new Error(\n 'moduleName is required when providing controllers without a module',\n )\n }\n }\n }\n\n /**\n * Registers controllers under a synthetic module.\n * Used when plugins want to add controllers without a full module class.\n */\n private async registerControllers(\n controllers: ClassType[],\n moduleName: string,\n ): Promise<void> {\n if (this.modulesMetadata.has(moduleName)) {\n // Merge controllers into existing module\n const existing = this.modulesMetadata.get(moduleName)!\n for (const controller of controllers) {\n existing.controllers.add(controller)\n }\n this.logger.debug(\n `Extended module ${moduleName} with ${controllers.length} controllers`,\n )\n } else {\n // Create new synthetic module metadata\n const metadata: ModuleMetadata = {\n controllers: new Set(controllers),\n imports: new Set(),\n guards: new Set(),\n customAttributes: new Map(),\n }\n this.modulesMetadata.set(moduleName, metadata)\n\n this.logger.debug(\n `Created module ${moduleName} with ${controllers.length} controllers`,\n )\n }\n }\n\n private async traverseModules(\n module: ClassTypeWithInstance<NaviosModule>,\n parentMetadata?: ModuleMetadata,\n ) {\n const metadata = extractModuleMetadata(module)\n if (parentMetadata) {\n this.mergeMetadata(metadata, parentMetadata)\n }\n const moduleName = module.name\n if (this.modulesMetadata.has(moduleName)) {\n return\n }\n try {\n this.modulesMetadata.set(moduleName, metadata)\n const imports = metadata.imports ?? new Set()\n const loadingPromises = Array.from(imports).map(async (importedModule) =>\n this.traverseModules(importedModule, metadata),\n )\n await Promise.all(loadingPromises)\n const instance = await this.container.get(module)\n if (instance.onModuleInit) {\n await instance.onModuleInit()\n }\n this.logger.debug(`Module ${moduleName} loaded`)\n this.loadedModules.set(moduleName, instance)\n } catch (error) {\n this.logger.error(`Error loading module ${moduleName}`, error)\n throw error\n }\n }\n\n private mergeMetadata(\n metadata: ModuleMetadata,\n parentMetadata: ModuleMetadata,\n ): void {\n if (parentMetadata.guards) {\n for (const guard of parentMetadata.guards) {\n metadata.guards.add(guard)\n }\n }\n if (parentMetadata.customAttributes) {\n for (const [key, value] of parentMetadata.customAttributes) {\n if (metadata.customAttributes.has(key)) {\n continue\n }\n metadata.customAttributes.set(key, value)\n }\n }\n }\n getAllModules(): Map<string, ModuleMetadata> {\n return this.modulesMetadata\n }\n dispose() {\n this.modulesMetadata.clear()\n this.loadedModules.clear()\n this.initialized = false\n }\n}\n","import type { ClassType } from '@navios/di'\nimport type { z, ZodType } from 'zod/v4'\n\nimport type {\n ControllerMetadata,\n HandlerMetadata,\n ModuleMetadata,\n} from './metadata/index.mjs'\n\nimport {\n getControllerMetadata,\n getEndpointMetadata,\n getModuleMetadata,\n hasControllerMetadata,\n hasModuleMetadata,\n} from './metadata/index.mjs'\n\n/**\n * Type for a class attribute decorator without a value.\n * \n * Attributes are custom metadata decorators that can be applied to modules,\n * controllers, and endpoints.\n */\nexport type ClassAttribute = (() => <T>(\n target: T,\n context: ClassDecoratorContext | ClassMethodDecoratorContext,\n) => T) & {\n token: symbol\n}\n\n/**\n * Type for a class attribute decorator with a validated value.\n * \n * @typeParam T - The Zod schema type for validation\n */\nexport type ClassSchemaAttribute<T extends ZodType> = ((\n value: z.input<T>,\n) => <T>(\n target: T,\n context: ClassDecoratorContext | ClassMethodDecoratorContext,\n) => T) & {\n token: symbol\n schema: ZodType\n}\n\n/**\n * Factory for creating custom attribute decorators.\n * \n * Attributes allow you to add custom metadata to modules, controllers, and endpoints.\n * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.\n * \n * @example\n * ```typescript\n * // Create a simple boolean attribute\n * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * \n * // Use it as a decorator\n * @Controller()\n * @Public()\n * export class PublicController { }\n * \n * // Check if attribute exists\n * if (AttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n * \n * @example\n * ```typescript\n * // Create an attribute with a validated value\n * const RateLimit = AttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n * \n * // Use it with a value\n * @Endpoint(apiEndpoint)\n * @RateLimit({ requests: 100, window: 60000 })\n * async handler() { }\n * \n * // Get the value\n * const limit = AttributeFactory.get(RateLimit, endpointMetadata)\n * // limit is typed as { requests: number, window: number } | null\n * ```\n */\nexport class AttributeFactory {\n /**\n * Creates a simple attribute decorator without a value.\n * \n * @param token - A unique symbol to identify this attribute\n * @returns A decorator function that can be applied to classes or methods\n * \n * @example\n * ```typescript\n * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * \n * @Public()\n * @Controller()\n * export class PublicController { }\n * ```\n */\n static createAttribute(token: symbol): ClassAttribute\n /**\n * Creates an attribute decorator with a validated value.\n * \n * @param token - A unique symbol to identify this attribute\n * @param schema - A Zod schema to validate the attribute value\n * @returns A decorator function that accepts a value and can be applied to classes or methods\n * \n * @example\n * ```typescript\n * const RateLimit = AttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n * \n * @RateLimit({ requests: 100, window: 60000 })\n * @Endpoint(apiEndpoint)\n * async handler() { }\n * ```\n */\n static createAttribute<T extends ZodType>(\n token: symbol,\n schema: T,\n ): ClassSchemaAttribute<T>\n static createAttribute(token: symbol, schema?: ZodType) {\n const res =\n (value?: unknown) =>\n (\n target: any,\n context: ClassDecoratorContext | ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'class' && context.kind !== 'method') {\n throw new Error(\n '[Navios] Attribute can only be applied to classes or methods',\n )\n }\n const isController =\n context.kind === 'class' && hasControllerMetadata(target as ClassType)\n const isModule =\n context.kind === 'class' && hasModuleMetadata(target as ClassType)\n if (context.kind === 'class' && !isController && !isModule) {\n throw new Error(\n '[Navios] Attribute can only be applied to classes with @Controller or @Module decorators',\n )\n }\n let metadata =\n context.kind === 'class'\n ? isController\n ? getControllerMetadata(target as any, context)\n : getModuleMetadata(target as any, context)\n : getEndpointMetadata(target, context)\n if (schema) {\n const validatedValue = schema.safeParse(value)\n if (!validatedValue.success) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${validatedValue.error}`,\n )\n }\n metadata.customAttributes.set(token, validatedValue.data)\n } else {\n metadata.customAttributes.set(token, true)\n }\n return target\n }\n res.token = token\n if (schema) {\n res.schema = schema\n }\n return res\n }\n\n /**\n * Gets the value of an attribute from metadata.\n * \n * Returns `null` if the attribute is not present.\n * For simple attributes (without values), returns `true` if present.\n * \n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns The attribute value, `true` for simple attributes, or `null` if not found\n * \n * @example\n * ```typescript\n * const isPublic = AttributeFactory.get(Public, controllerMetadata)\n * // isPublic is true | null\n * \n * const rateLimit = AttributeFactory.get(RateLimit, endpointMetadata)\n * // rateLimit is { requests: number, window: number } | null\n * ```\n */\n static get(\n attribute: ClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): true | null\n static get<T extends ZodType>(\n attribute: ClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): z.output<T> | null\n static get(\n attribute: ClassAttribute | ClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.get(attribute.token) ?? null\n }\n\n /**\n * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).\n * \n * Returns `null` if the attribute is not present.\n * \n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns An array of attribute values, or `null` if not found\n * \n * @example\n * ```typescript\n * const tags = AttributeFactory.getAll(Tag, endpointMetadata)\n * // tags is string[] | null\n * ```\n */\n static getAll(\n attribute: ClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<true> | null\n static getAll<T extends ZodType>(\n attribute: ClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<z.output<T>> | null\n static getAll(\n attribute: ClassAttribute | ClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n const values = Array.from(target.customAttributes.entries())\n .filter(([key]) => key === attribute.token)\n .map(([, value]) => value)\n return values.length > 0 ? values : null\n }\n\n /**\n * Gets the last value of an attribute from an array of metadata objects.\n * \n * Searches from the end of the array backwards, useful for finding the most\n * specific attribute value (e.g., endpoint-level overrides module-level).\n * \n * @param attribute - The attribute decorator\n * @param target - An array of metadata objects (typically [module, controller, handler])\n * @returns The last attribute value found, or `null` if not found\n * \n * @example\n * ```typescript\n * // Check attribute hierarchy: endpoint -> controller -> module\n * const rateLimit = AttributeFactory.getLast(RateLimit, [\n * moduleMetadata,\n * controllerMetadata,\n * endpointMetadata\n * ])\n * ```\n */\n static getLast(\n attribute: ClassAttribute,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): true | null\n static getLast<T extends ZodType>(\n attribute: ClassSchemaAttribute<T>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): z.output<T> | null\n static getLast(\n attribute: ClassAttribute | ClassSchemaAttribute<any>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ) {\n for (let i = target.length - 1; i >= 0; i--) {\n const value = target[i].customAttributes.get(attribute.token)\n if (value) {\n return value\n }\n }\n return null\n }\n\n /**\n * Checks if an attribute is present on the metadata object.\n * \n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns `true` if the attribute is present, `false` otherwise\n * \n * @example\n * ```typescript\n * if (AttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n */\n static has(\n attribute: ClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has<T extends ZodType>(\n attribute: ClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has(\n attribute: ClassAttribute | ClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.has(attribute.token)\n }\n}\n","import type { AnyInjectableType, InjectionToken } from '@navios/di'\n\nimport { Injectable } from '@navios/di'\n\nexport interface NaviosEnvironmentOptions {\n // Future options can be added here\n httpTokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>\n}\n\n@Injectable()\nexport class NaviosEnvironment {\n private httpTokens = new Map<\n InjectionToken<any, undefined>,\n AnyInjectableType\n >()\n\n setupHttpEnvironment(\n tokens: Map<InjectionToken<any, undefined>, AnyInjectableType>,\n ) {\n this.httpTokens = tokens\n }\n\n getHttpToken(token: InjectionToken<any, undefined>) {\n return this.httpTokens.get(token)\n }\n\n hasHttpSetup() {\n return this.httpTokens.size > 0\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { EndpointAdapterToken } from '../tokens/index.mjs'\n\n@Factory({\n token: EndpointAdapterToken,\n})\nexport class EndpointAdapterFactory {\n private readonly environment = inject(NaviosEnvironment)\n\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(EndpointAdapterToken)\n if (!service) {\n throw new Error('EndpointAdapterToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext } from '@navios/di'\n\nimport { Factory, inject, InjectionToken } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { HttpAdapterToken } from '../tokens/index.mjs'\n\n@Factory({\n token: HttpAdapterToken,\n})\nexport class HttpAdapterFactory {\n private readonly environment = inject(NaviosEnvironment)\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(HttpAdapterToken)\n if (!service) {\n throw new Error('HttpAdapterToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { MultipartAdapterToken } from '../tokens/index.mjs'\n\n@Factory({\n token: MultipartAdapterToken,\n})\nexport class MultipartAdapterFactory {\n private readonly environment = inject(NaviosEnvironment)\n\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(MultipartAdapterToken)\n if (!service) {\n throw new Error('MultipartAdapterToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject, InjectableScope } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { Request } from '../tokens/index.mjs'\n\n@Factory({\n token: Request,\n scope: InjectableScope.Request,\n})\nexport class RequestFactory {\n private readonly environment = inject(NaviosEnvironment)\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(Request)\n if (!service) {\n throw new Error('RequestToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject, InjectableScope } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { Reply } from '../tokens/index.mjs'\n\n@Factory({\n token: Reply,\n scope: InjectableScope.Request,\n})\nexport class ReplyFactory {\n private readonly environment = inject(NaviosEnvironment)\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(Reply)\n if (!service) {\n throw new Error('ReplyToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { StreamAdapterToken } from '../tokens/index.mjs'\n\n@Factory({\n token: StreamAdapterToken,\n})\nexport class StreamAdapterFactory {\n private readonly environment = inject(NaviosEnvironment)\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(StreamAdapterToken)\n if (!service) {\n throw new Error('StreamAdapterToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { FactoryContext, InjectionToken } from '@navios/di'\n\nimport { Factory, inject } from '@navios/di'\n\nimport { NaviosEnvironment } from '../navios.environment.mjs'\nimport { XmlStreamAdapterToken } from '../tokens/index.mjs'\n\n@Factory({\n token: XmlStreamAdapterToken,\n})\nexport class XmlStreamAdapterFactory {\n private readonly environment = inject(NaviosEnvironment)\n create(ctx: FactoryContext) {\n const service = this.environment.getHttpToken(XmlStreamAdapterToken)\n if (!service) {\n throw new Error('XmlStreamAdapterToken service not found in environment')\n }\n return ctx.inject(service as InjectionToken<any, undefined>)\n }\n}\n","import type { ClassTypeWithInstance } from '@navios/di'\n\nimport { Container, inject, Injectable } from '@navios/di'\n\nimport type {\n AbstractHttpAdapterInterface,\n AbstractHttpListenOptions,\n NaviosModule,\n PluginContext,\n PluginDefinition,\n} from './interfaces/index.mjs'\nimport type { LoggerService, LogLevel } from './logger/index.mjs'\nimport type { NaviosEnvironmentOptions } from './navios.environment.mjs'\n\nimport { HttpAdapterToken } from './index.mjs'\nimport { Logger } from './logger/index.mjs'\nimport { NaviosEnvironment } from './navios.environment.mjs'\nimport { ModuleLoaderService } from './services/index.mjs'\n\n/**\n * Options for configuring the Navios application context.\n * These options control dependency injection and logging behavior.\n */\nexport interface NaviosApplicationContextOptions {\n /**\n * Specifies the logger to use. Pass `false` to turn off logging.\n *\n * - `LoggerService` instance: Use a custom logger implementation\n * - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])\n * - `false`: Disable logging completely\n */\n logger?: LoggerService | LogLevel[] | false\n\n /**\n * Specifies a custom container to use. Useful for testing.\n * If not provided, a new Container will be created.\n */\n container?: Container\n}\n\n/**\n * Complete options for creating a Navios application.\n * Extends NaviosApplicationContextOptions with adapter configuration.\n */\nexport interface NaviosApplicationOptions extends NaviosApplicationContextOptions {\n /**\n * HTTP adapter environment(s) to use for the application.\n * Can be a single adapter or an array of adapters.\n *\n * @example\n * ```typescript\n * adapter: defineFastifyEnvironment()\n * // or\n * adapter: [defineFastifyEnvironment(), defineBunEnvironment()]\n * ```\n */\n adapter: NaviosEnvironmentOptions | NaviosEnvironmentOptions[]\n}\n\n/**\n * Main application class for Navios.\n *\n * This class represents a Navios application instance and provides methods\n * for initializing, configuring, and managing the HTTP server.\n *\n * @example\n * ```typescript\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * })\n *\n * app.setGlobalPrefix('/api')\n * app.enableCors({ origin: ['http://localhost:3000'] })\n * await app.init()\n * await app.listen({ port: 3000, host: '0.0.0.0' })\n * ```\n */\n@Injectable()\nexport class NaviosApplication {\n private environment = inject(NaviosEnvironment)\n private moduleLoader = inject(ModuleLoaderService)\n private httpApplication: AbstractHttpAdapterInterface<any> | null = null\n private logger = inject(Logger, {\n context: NaviosApplication.name,\n })\n protected container = inject(Container)\n\n private appModule: ClassTypeWithInstance<NaviosModule> | null = null\n private options: NaviosApplicationOptions = {\n adapter: [],\n }\n private plugins: PluginDefinition<any>[] = []\n\n /**\n * Indicates whether the application has been initialized.\n * Set to `true` after `init()` completes successfully.\n */\n isInitialized = false\n\n /**\n * Sets up the application with the provided module and options.\n * This is called automatically by NaviosFactory.create().\n *\n * @param appModule - The root application module\n * @param options - Application configuration options\n * @internal\n */\n async setup(\n appModule: ClassTypeWithInstance<NaviosModule>,\n options: NaviosApplicationOptions = {\n adapter: [],\n },\n ) {\n this.appModule = appModule\n this.options = options\n if (this.environment.hasHttpSetup()) {\n this.httpApplication = await this.container.get(HttpAdapterToken)\n }\n }\n\n /**\n * Gets the dependency injection container used by this application.\n *\n * @returns The Container instance\n */\n getContainer() {\n return this.container\n }\n\n /**\n * Registers a plugin to be initialized after modules are loaded.\n *\n * Plugins are initialized in the order they are registered,\n * after all modules are loaded but before the server starts listening.\n *\n * @param definition - Plugin definition with options\n * @returns this for method chaining\n *\n * @example\n * ```typescript\n * import { defineOpenApiPlugin } from '@navios/openapi-fastify'\n *\n * app.usePlugin(defineOpenApiPlugin({\n * info: { title: 'My API', version: '1.0.0' },\n * }))\n * ```\n */\n usePlugin<TOptions>(definition: PluginDefinition<TOptions>): this {\n this.plugins.push(definition)\n return this\n }\n\n /**\n * Initializes the application.\n *\n * This method:\n * - Loads all modules and their dependencies\n * - Sets up the HTTP server if an adapter is configured\n * - Calls onModuleInit hooks on all modules\n * - Initializes registered plugins\n * - Marks the application as initialized\n *\n * Must be called before `listen()`.\n *\n * @throws Error if app module is not set\n *\n * @example\n * ```typescript\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * })\n * await app.init()\n * await app.listen({ port: 3000 })\n * ```\n */\n async init() {\n if (!this.appModule) {\n throw new Error('App module is not set. Call setAppModule() first.')\n }\n await this.moduleLoader.loadModules(this.appModule)\n if (this.environment.hasHttpSetup()) {\n await this.httpApplication?.setupHttpServer(this.options)\n }\n await this.initPlugins()\n await this.initModules()\n if (this.environment.hasHttpSetup()) {\n await this.httpApplication?.ready()\n }\n\n this.isInitialized = true\n this.logger.debug('Navios application initialized')\n }\n\n private async initModules() {\n const modules = this.moduleLoader.getAllModules()\n await this.httpApplication?.onModulesInit(modules)\n }\n\n private async initPlugins() {\n if (this.plugins.length === 0) return\n\n let server: any = null\n try {\n server = this.httpApplication?.getServer() ?? null\n } catch {\n // ignore\n }\n const context: PluginContext = {\n modules: this.moduleLoader.getAllModules(),\n server,\n container: this.container,\n globalPrefix: this.httpApplication?.getGlobalPrefix() ?? '',\n moduleLoader: this.moduleLoader,\n }\n\n for (const { plugin, options } of this.plugins) {\n this.logger.debug(`Initializing plugin: ${plugin.name}`)\n await plugin.register(context, options)\n }\n }\n\n /**\n * Enables CORS (Cross-Origin Resource Sharing) for the application.\n *\n * @param options - CORS configuration options (adapter-specific)\n * @throws Error if HTTP application is not set\n *\n * @example\n * ```typescript\n * app.enableCors({\n * origin: ['http://localhost:3000', 'https://example.com'],\n * methods: ['GET', 'POST', 'PUT', 'DELETE'],\n * credentials: true,\n * })\n * ```\n */\n enableCors(options: any) {\n if (!this.httpApplication) {\n throw new Error('HTTP application is not set')\n }\n this.httpApplication.enableCors(options)\n }\n\n /**\n * Enables multipart/form-data support for file uploads.\n *\n * @param options - Multipart configuration options (adapter-specific)\n * @throws Error if HTTP application is not set\n *\n * @example\n * ```typescript\n * app.enableMultipart({\n * limits: {\n * fileSize: 1024 * 1024 * 10, // 10MB\n * },\n * })\n * ```\n */\n enableMultipart(options: any) {\n if (!this.httpApplication) {\n throw new Error('HTTP application is not set')\n }\n this.httpApplication.enableMultipart(options)\n }\n\n /**\n * Sets a global prefix for all routes.\n *\n * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')\n * @throws Error if HTTP application is not set\n *\n * @example\n * ```typescript\n * app.setGlobalPrefix('/api/v1')\n * // All routes will be prefixed with /api/v1\n * ```\n */\n setGlobalPrefix(prefix: string) {\n if (!this.httpApplication) {\n throw new Error('HTTP application is not set')\n }\n this.httpApplication.setGlobalPrefix(prefix)\n }\n\n /**\n * Gets the underlying HTTP server instance.\n *\n * The type of the returned server depends on the adapter used:\n * - Fastify adapter: Returns FastifyInstance\n * - Bun adapter: Returns Bun.Server\n *\n * @returns The HTTP server instance\n * @throws Error if HTTP application is not set\n *\n * @example\n * ```typescript\n * const server = app.getServer()\n * // Use adapter-specific server methods\n * ```\n */\n getServer() {\n if (!this.httpApplication) {\n throw new Error('HTTP application is not set')\n }\n return this.httpApplication.getServer()\n }\n\n /**\n * Starts the HTTP server and begins listening for requests.\n *\n * @param options - Listen options (port, host, etc.)\n * @throws Error if HTTP application is not set\n *\n * @example\n * ```typescript\n * await app.listen({ port: 3000, host: '0.0.0.0' })\n * ```\n */\n async listen(options: AbstractHttpListenOptions) {\n if (!this.httpApplication) {\n throw new Error('HTTP application is not set')\n }\n await this.httpApplication.listen(options)\n }\n\n /**\n * Disposes of application resources.\n *\n * Cleans up the HTTP server and module loader.\n * This method is called automatically by `close()`.\n */\n async dispose() {\n if (this.httpApplication) {\n await this.httpApplication.dispose()\n }\n if (this.moduleLoader) {\n this.moduleLoader.dispose()\n }\n }\n\n /**\n * Closes the application and cleans up all resources.\n *\n * This is an alias for `dispose()`.\n *\n * @example\n * ```typescript\n * // Graceful shutdown\n * process.on('SIGTERM', async () => {\n * await app.close()\n * process.exit(0)\n * })\n * ```\n */\n async close() {\n await this.dispose()\n }\n}\n","import type {\n AnyInjectableType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport { Container, InjectableScope, InjectableType } from '@navios/di'\n\nimport type { NaviosModule } from './interfaces/index.mjs'\nimport type {\n NaviosApplicationContextOptions,\n NaviosApplicationOptions,\n} from './navios.application.mjs'\n\nimport { ConsoleLogger, isNil, LoggerOutput } from './logger/index.mjs'\nimport { NaviosApplication } from './navios.application.mjs'\nimport { NaviosEnvironment } from './navios.environment.mjs'\n\n/**\n * Factory class for creating and configuring Navios applications.\n *\n * This is the main entry point for bootstrapping a Navios application.\n * It handles dependency injection container setup, adapter registration,\n * and logger configuration.\n *\n * @example\n * ```typescript\n * import { NaviosFactory } from '@navios/core'\n * import { defineFastifyEnvironment } from '@navios/adapter-fastify'\n *\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * logger: ['log', 'error', 'warn'],\n * })\n *\n * await app.init()\n * await app.listen({ port: 3000 })\n * ```\n */\nexport class NaviosFactory {\n /**\n * Creates a new Navios application instance.\n *\n * This method sets up the dependency injection container, registers the HTTP adapter,\n * configures logging, and initializes the application with the provided module.\n *\n * @param appModule - The root application module class decorated with @Module()\n * @param options - Configuration options for the application\n * @param options.adapter - HTTP adapter environment (required for HTTP server functionality)\n * @param options.logger - Logger configuration. Can be:\n * - A LoggerService instance for custom logging\n * - An array of LogLevel strings to enable specific log levels\n * - `false` to disable logging\n * @param options.container - Optional custom dependency injection container (useful for testing)\n * @returns A configured NaviosApplication instance ready to be initialized\n *\n * @example\n * ```typescript\n * // Basic setup with Fastify adapter\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * })\n *\n * // With custom logger configuration\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * logger: ['error', 'warn', 'log'],\n * })\n *\n * // With custom container for testing\n * const container = new Container()\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: defineFastifyEnvironment(),\n * container,\n * })\n * ```\n */\n static async create(\n appModule: ClassTypeWithInstance<NaviosModule>,\n options: NaviosApplicationOptions = {\n adapter: [],\n },\n ) {\n const container = options.container ?? new Container()\n await this.registerLoggerConfiguration(container, options)\n const adapters = Array.isArray(options.adapter)\n ? options.adapter\n : [options.adapter]\n for (const adapter of adapters) {\n await this.registerEnvironment(container, adapter)\n }\n const app = await container.get(NaviosApplication)\n await app.setup(appModule, options)\n return app\n }\n\n private static async registerEnvironment(\n container: Container,\n environment: {\n httpTokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>\n } = {},\n ) {\n const naviosEnvironment = await container.get(NaviosEnvironment)\n const { httpTokens } = environment\n if (httpTokens) {\n naviosEnvironment.setupHttpEnvironment(httpTokens)\n }\n }\n\n private static async registerLoggerConfiguration(\n container: Container,\n options: NaviosApplicationContextOptions,\n ) {\n const { logger } = options\n if (Array.isArray(logger) || isNil(logger)) {\n const loggerInstance = (await container.get(\n LoggerOutput,\n )) as ConsoleLogger\n loggerInstance?.setup({\n logLevels: logger,\n })\n return\n }\n if ((logger as boolean) !== true && !isNil(logger)) {\n container\n .getServiceLocator()\n .getManager()\n .storeCreatedHolder(\n LoggerOutput.toString(),\n logger,\n InjectableType.Class,\n InjectableScope.Singleton,\n )\n }\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAgB,OACd,KACA,cACQ;CACR,MAAM,SAAS,IAAI,QAAQ,QAAQ,IAAI;AAEvC,QAAO,SAAS,SAAS,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