@navios/core 0.7.0 → 0.8.0
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 +53 -0
- package/lib/{index-BFwNx9WQ.d.cts → index-BDNl7j1G.d.cts} +666 -292
- package/lib/index-BDNl7j1G.d.cts.map +1 -0
- package/lib/{index-D657ijFO.d.mts → index-BoP0cWT6.d.mts} +666 -292
- package/lib/index-BoP0cWT6.d.mts.map +1 -0
- package/lib/index.cjs +15 -6
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +3 -3
- package/lib/legacy-compat/index.cjs +1 -1
- package/lib/legacy-compat/index.cjs.map +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/legacy-compat/index.mjs +1 -1
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-Cb1aTjl0.cjs → src-B6eISODM.cjs} +622 -114
- package/lib/src-B6eISODM.cjs.map +1 -0
- package/lib/{src-DzPY5s6d.mjs → src-gBAChVRL.mjs} +563 -73
- package/lib/src-gBAChVRL.mjs.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 +2 -2
- package/lib/{use-guards.decorator-DdvUhB03.cjs → use-guards.decorator-COR-9mZY.cjs} +34 -108
- package/lib/use-guards.decorator-COR-9mZY.cjs.map +1 -0
- package/lib/{use-guards.decorator-kZ3lNK8v.mjs → use-guards.decorator-CUww54Nt.mjs} +14 -94
- package/lib/use-guards.decorator-CUww54Nt.mjs.map +1 -0
- package/package.json +12 -12
- package/src/__tests__/controller-resolver.spec.mts +223 -0
- package/src/__tests__/controller.spec.mts +1 -1
- package/src/decorators/controller.decorator.mts +11 -6
- package/src/decorators/endpoint.decorator.mts +60 -12
- package/src/decorators/multipart.decorator.mts +67 -24
- package/src/decorators/stream.decorator.mts +65 -24
- package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +31 -1
- package/src/interfaces/index.mts +1 -0
- package/src/interfaces/plugin.interface.mts +105 -0
- package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
- package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
- package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
- package/src/logger/logger.service.mts +3 -3
- package/src/navios.application.mts +91 -27
- package/src/navios.factory.mts +29 -9
- package/src/services/guard-runner.service.mts +46 -9
- package/src/services/index.mts +1 -0
- package/src/services/instance-resolver.service.mts +186 -0
- package/src/services/module-loader.service.mts +102 -1
- package/src/stores/request-id.store.mts +45 -3
- package/src/tokens/index.mts +1 -0
- package/src/tokens/navios-options.token.mts +6 -0
- 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/lib/use-guards.decorator-DdvUhB03.cjs.map +0 -1
- package/lib/use-guards.decorator-kZ3lNK8v.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
|
@@ -25,12 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_use_guards_decorator = require('./use-guards.decorator-
|
|
29
|
-
let
|
|
28
|
+
const require_use_guards_decorator = require('./use-guards.decorator-COR-9mZY.cjs');
|
|
29
|
+
let _navios_di = require("@navios/di");
|
|
30
30
|
let node_process = require("node:process");
|
|
31
31
|
let zod_v4 = require("zod/v4");
|
|
32
32
|
zod_v4 = __toESM(zod_v4);
|
|
33
|
-
let
|
|
33
|
+
let _navios_builder = require("@navios/builder");
|
|
34
34
|
let util = require("util");
|
|
35
35
|
let node_async_hooks = require("node:async_hooks");
|
|
36
36
|
|
|
@@ -138,6 +138,15 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
138
138
|
|
|
139
139
|
//#endregion
|
|
140
140
|
//#region src/stores/request-id.store.mts
|
|
141
|
+
let requestCounter = 0;
|
|
142
|
+
/**
|
|
143
|
+
* Generates a simple incremental request ID.
|
|
144
|
+
* Much faster than crypto.randomUUID() and sufficient for request tracking.
|
|
145
|
+
*
|
|
146
|
+
* @returns A unique request ID string (e.g., "req-1", "req-2", ...)
|
|
147
|
+
*/ function generateRequestId() {
|
|
148
|
+
return `req-${++requestCounter}`;
|
|
149
|
+
}
|
|
141
150
|
/**
|
|
142
151
|
* AsyncLocalStorage store for the current request ID.
|
|
143
152
|
*
|
|
@@ -157,22 +166,42 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
157
166
|
* // Get current request ID (returns undefined if not in a request context)
|
|
158
167
|
* const currentId = getRequestId()
|
|
159
168
|
* ```
|
|
160
|
-
*/
|
|
169
|
+
*/ let requestIdStore = null;
|
|
170
|
+
function getRequestIdStore() {
|
|
171
|
+
if (!requestIdStore) requestIdStore = new node_async_hooks.AsyncLocalStorage();
|
|
172
|
+
return requestIdStore;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether request ID propagation is enabled.
|
|
176
|
+
* When disabled, runWithRequestId is a pass-through for better performance.
|
|
177
|
+
*/ let requestIdEnabled = false;
|
|
178
|
+
/**
|
|
179
|
+
* Enables or disables request ID propagation.
|
|
180
|
+
* Called by NaviosFactory based on the enableRequestId option.
|
|
181
|
+
*
|
|
182
|
+
* @param enabled - Whether to enable request ID propagation
|
|
183
|
+
*/ function setRequestIdEnabled(enabled) {
|
|
184
|
+
requestIdEnabled = enabled;
|
|
185
|
+
}
|
|
161
186
|
/**
|
|
162
187
|
* Runs a function with a request ID in the async local storage context.
|
|
188
|
+
* If request ID propagation is disabled, the function is called directly
|
|
189
|
+
* without AsyncLocalStorage overhead.
|
|
163
190
|
*
|
|
164
191
|
* @param requestId - The request ID to set for this context
|
|
165
192
|
* @param fn - The function to run within this context
|
|
166
193
|
* @returns The return value of the function
|
|
167
194
|
*/ function runWithRequestId(requestId, fn) {
|
|
168
|
-
|
|
195
|
+
if (!requestIdEnabled) return fn();
|
|
196
|
+
return getRequestIdStore().run(requestId, fn);
|
|
169
197
|
}
|
|
170
198
|
/**
|
|
171
199
|
* Gets the current request ID from the async local storage context.
|
|
172
200
|
*
|
|
173
201
|
* @returns The current request ID, or undefined if not in a request context
|
|
174
202
|
*/ function getRequestId() {
|
|
175
|
-
|
|
203
|
+
if (!requestIdEnabled) return;
|
|
204
|
+
return getRequestIdStore().getStore();
|
|
176
205
|
}
|
|
177
206
|
|
|
178
207
|
//#endregion
|
|
@@ -182,7 +211,7 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
182
211
|
*
|
|
183
212
|
* This token is used to provide a custom logger implementation.
|
|
184
213
|
* By default, it's bound to ConsoleLogger.
|
|
185
|
-
*/ const LoggerOutput =
|
|
214
|
+
*/ const LoggerOutput = _navios_di.InjectionToken.create("LoggerOutput");
|
|
186
215
|
/**
|
|
187
216
|
* Schema for logger options.
|
|
188
217
|
*/ const loggerOptionsSchema = zod_v4.default.object({ context: zod_v4.default.string().optional() }).optional();
|
|
@@ -196,11 +225,11 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
196
225
|
* const logger = inject(Logger, { context: 'MyService' })
|
|
197
226
|
* logger.log('Hello world') // Logs with context: [MyService]
|
|
198
227
|
* ```
|
|
199
|
-
*/ const Logger =
|
|
228
|
+
*/ const Logger = _navios_di.InjectionToken.create("Logger", loggerOptionsSchema);
|
|
200
229
|
|
|
201
230
|
//#endregion
|
|
202
231
|
//#region src/logger/console-logger.service.mts
|
|
203
|
-
function applyDecs2203RFactory$
|
|
232
|
+
function applyDecs2203RFactory$14() {
|
|
204
233
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
205
234
|
return function addInitializer(initializer) {
|
|
206
235
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -474,10 +503,10 @@ function applyDecs2203RFactory$13() {
|
|
|
474
503
|
};
|
|
475
504
|
};
|
|
476
505
|
}
|
|
477
|
-
function _apply_decs_2203_r$
|
|
478
|
-
return (_apply_decs_2203_r$
|
|
506
|
+
function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass) {
|
|
507
|
+
return (_apply_decs_2203_r$14 = applyDecs2203RFactory$14())(targetClass, memberDecs, classDecs, parentClass);
|
|
479
508
|
}
|
|
480
|
-
var _dec$
|
|
509
|
+
var _dec$14, _initClass$14;
|
|
481
510
|
const DEFAULT_DEPTH = 5;
|
|
482
511
|
const DEFAULT_LOG_LEVELS = [
|
|
483
512
|
"log",
|
|
@@ -496,10 +525,10 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
|
496
525
|
month: "2-digit"
|
|
497
526
|
});
|
|
498
527
|
let _ConsoleLogger;
|
|
499
|
-
_dec$
|
|
528
|
+
_dec$14 = (0, _navios_di.Injectable)({ token: LoggerOutput });
|
|
500
529
|
var ConsoleLogger = class {
|
|
501
530
|
static {
|
|
502
|
-
({c: [_ConsoleLogger, _initClass$
|
|
531
|
+
({c: [_ConsoleLogger, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
|
|
503
532
|
}
|
|
504
533
|
/**
|
|
505
534
|
* The options of the logger.
|
|
@@ -748,13 +777,13 @@ var ConsoleLogger = class {
|
|
|
748
777
|
}
|
|
749
778
|
}
|
|
750
779
|
static {
|
|
751
|
-
_initClass$
|
|
780
|
+
_initClass$14();
|
|
752
781
|
}
|
|
753
782
|
};
|
|
754
783
|
|
|
755
784
|
//#endregion
|
|
756
785
|
//#region src/logger/logger.service.mts
|
|
757
|
-
function applyDecs2203RFactory$
|
|
786
|
+
function applyDecs2203RFactory$13() {
|
|
758
787
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
759
788
|
return function addInitializer(initializer) {
|
|
760
789
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -1028,20 +1057,20 @@ function applyDecs2203RFactory$12() {
|
|
|
1028
1057
|
};
|
|
1029
1058
|
};
|
|
1030
1059
|
}
|
|
1031
|
-
function _apply_decs_2203_r$
|
|
1032
|
-
return (_apply_decs_2203_r$
|
|
1060
|
+
function _apply_decs_2203_r$13(targetClass, memberDecs, classDecs, parentClass) {
|
|
1061
|
+
return (_apply_decs_2203_r$13 = applyDecs2203RFactory$13())(targetClass, memberDecs, classDecs, parentClass);
|
|
1033
1062
|
}
|
|
1034
|
-
var _dec$
|
|
1063
|
+
var _dec$13, _initClass$13;
|
|
1035
1064
|
let _LoggerInstance;
|
|
1036
|
-
_dec$
|
|
1065
|
+
_dec$13 = (0, _navios_di.Injectable)({ token: Logger });
|
|
1037
1066
|
var LoggerInstance = class {
|
|
1038
1067
|
static {
|
|
1039
|
-
({c: [_LoggerInstance, _initClass$
|
|
1068
|
+
({c: [_LoggerInstance, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
|
|
1040
1069
|
}
|
|
1041
1070
|
constructor(config = {}) {
|
|
1042
1071
|
this.context = config.context;
|
|
1043
1072
|
}
|
|
1044
|
-
localInstance = (0,
|
|
1073
|
+
localInstance = (0, _navios_di.inject)(LoggerOutput);
|
|
1045
1074
|
context;
|
|
1046
1075
|
error(message, ...optionalParams) {
|
|
1047
1076
|
optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(this.context) : optionalParams;
|
|
@@ -1068,13 +1097,13 @@ var LoggerInstance = class {
|
|
|
1068
1097
|
this.localInstance?.fatal?.(message, ...optionalParams);
|
|
1069
1098
|
}
|
|
1070
1099
|
static {
|
|
1071
|
-
_initClass$
|
|
1100
|
+
_initClass$13();
|
|
1072
1101
|
}
|
|
1073
1102
|
};
|
|
1074
1103
|
|
|
1075
1104
|
//#endregion
|
|
1076
1105
|
//#region src/config/config.service.mts
|
|
1077
|
-
function applyDecs2203RFactory$
|
|
1106
|
+
function applyDecs2203RFactory$12() {
|
|
1078
1107
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1079
1108
|
return function addInitializer(initializer) {
|
|
1080
1109
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -1348,22 +1377,22 @@ function applyDecs2203RFactory$11() {
|
|
|
1348
1377
|
};
|
|
1349
1378
|
};
|
|
1350
1379
|
}
|
|
1351
|
-
function _apply_decs_2203_r$
|
|
1352
|
-
return (_apply_decs_2203_r$
|
|
1380
|
+
function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass) {
|
|
1381
|
+
return (_apply_decs_2203_r$12 = applyDecs2203RFactory$12())(targetClass, memberDecs, classDecs, parentClass);
|
|
1353
1382
|
}
|
|
1354
|
-
var _dec$
|
|
1383
|
+
var _dec$12, _initClass$12;
|
|
1355
1384
|
/**
|
|
1356
1385
|
* Schema for validating configuration service options.
|
|
1357
1386
|
*/ const ConfigServiceOptionsSchema = zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown());
|
|
1358
1387
|
/**
|
|
1359
1388
|
* Injection token for ConfigService.
|
|
1360
|
-
*/ const ConfigServiceToken =
|
|
1389
|
+
*/ const ConfigServiceToken = _navios_di.InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
|
|
1361
1390
|
let _ConfigService;
|
|
1362
|
-
_dec$
|
|
1391
|
+
_dec$12 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
|
|
1363
1392
|
var ConfigService = class {
|
|
1364
1393
|
config;
|
|
1365
1394
|
static {
|
|
1366
|
-
({c: [_ConfigService, _initClass$
|
|
1395
|
+
({c: [_ConfigService, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
|
|
1367
1396
|
}
|
|
1368
1397
|
/**
|
|
1369
1398
|
* Creates a new ConfigService instance.
|
|
@@ -1372,7 +1401,7 @@ var ConfigService = class {
|
|
|
1372
1401
|
*/ constructor(config = {}) {
|
|
1373
1402
|
this.config = config;
|
|
1374
1403
|
}
|
|
1375
|
-
logger = (0,
|
|
1404
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ConfigService.name });
|
|
1376
1405
|
/**
|
|
1377
1406
|
* Gets the entire configuration object.
|
|
1378
1407
|
*
|
|
@@ -1440,12 +1469,12 @@ var ConfigService = class {
|
|
|
1440
1469
|
if (value === null) {
|
|
1441
1470
|
const message = errorMessage || `Configuration value for key "${String(key)}" is not defined`;
|
|
1442
1471
|
this.logger.error(message);
|
|
1443
|
-
throw new
|
|
1472
|
+
throw new _navios_builder.NaviosError(message);
|
|
1444
1473
|
}
|
|
1445
1474
|
return value;
|
|
1446
1475
|
}
|
|
1447
1476
|
static {
|
|
1448
|
-
_initClass$
|
|
1477
|
+
_initClass$12();
|
|
1449
1478
|
}
|
|
1450
1479
|
};
|
|
1451
1480
|
|
|
@@ -1476,7 +1505,7 @@ var ConfigService = class {
|
|
|
1476
1505
|
* container.bind(ConfigServiceToken).toFactory(configProvider)
|
|
1477
1506
|
* ```
|
|
1478
1507
|
*/ function provideConfig(options) {
|
|
1479
|
-
return
|
|
1508
|
+
return _navios_di.InjectionToken.factory(ConfigServiceToken, async () => options.load());
|
|
1480
1509
|
}
|
|
1481
1510
|
/**
|
|
1482
1511
|
* Pre-configured ConfigService provider that uses environment variables.
|
|
@@ -1488,7 +1517,7 @@ var ConfigService = class {
|
|
|
1488
1517
|
* // Use environment variables as configuration
|
|
1489
1518
|
* container.bind(ConfigServiceToken).toValue(EnvConfigProvider)
|
|
1490
1519
|
* ```
|
|
1491
|
-
*/ const EnvConfigProvider =
|
|
1520
|
+
*/ const EnvConfigProvider = _navios_di.InjectionToken.bound(ConfigServiceToken, { ...node_process.env });
|
|
1492
1521
|
|
|
1493
1522
|
//#endregion
|
|
1494
1523
|
//#region src/exceptions/http.exception.mts
|
|
@@ -1705,6 +1734,360 @@ var ConfigService = class {
|
|
|
1705
1734
|
}
|
|
1706
1735
|
};
|
|
1707
1736
|
|
|
1737
|
+
//#endregion
|
|
1738
|
+
//#region src/services/instance-resolver.service.mts
|
|
1739
|
+
function applyDecs2203RFactory$11() {
|
|
1740
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1741
|
+
return function addInitializer(initializer) {
|
|
1742
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
1743
|
+
assertCallable(initializer, "An initializer");
|
|
1744
|
+
initializers.push(initializer);
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
1748
|
+
var kindStr;
|
|
1749
|
+
switch (kind) {
|
|
1750
|
+
case 1:
|
|
1751
|
+
kindStr = "accessor";
|
|
1752
|
+
break;
|
|
1753
|
+
case 2:
|
|
1754
|
+
kindStr = "method";
|
|
1755
|
+
break;
|
|
1756
|
+
case 3:
|
|
1757
|
+
kindStr = "getter";
|
|
1758
|
+
break;
|
|
1759
|
+
case 4:
|
|
1760
|
+
kindStr = "setter";
|
|
1761
|
+
break;
|
|
1762
|
+
default: kindStr = "field";
|
|
1763
|
+
}
|
|
1764
|
+
var ctx = {
|
|
1765
|
+
kind: kindStr,
|
|
1766
|
+
name: isPrivate ? "#" + name : name,
|
|
1767
|
+
static: isStatic,
|
|
1768
|
+
private: isPrivate,
|
|
1769
|
+
metadata
|
|
1770
|
+
};
|
|
1771
|
+
var decoratorFinishedRef = { v: false };
|
|
1772
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
1773
|
+
var get, set;
|
|
1774
|
+
if (kind === 0) if (isPrivate) {
|
|
1775
|
+
get = desc.get;
|
|
1776
|
+
set = desc.set;
|
|
1777
|
+
} else {
|
|
1778
|
+
get = function() {
|
|
1779
|
+
return this[name];
|
|
1780
|
+
};
|
|
1781
|
+
set = function(v) {
|
|
1782
|
+
this[name] = v;
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
else if (kind === 2) get = function() {
|
|
1786
|
+
return desc.value;
|
|
1787
|
+
};
|
|
1788
|
+
else {
|
|
1789
|
+
if (kind === 1 || kind === 3) get = function() {
|
|
1790
|
+
return desc.get.call(this);
|
|
1791
|
+
};
|
|
1792
|
+
if (kind === 1 || kind === 4) set = function(v) {
|
|
1793
|
+
desc.set.call(this, v);
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
ctx.access = get && set ? {
|
|
1797
|
+
get,
|
|
1798
|
+
set
|
|
1799
|
+
} : get ? { get } : { set };
|
|
1800
|
+
try {
|
|
1801
|
+
return dec(value, ctx);
|
|
1802
|
+
} finally {
|
|
1803
|
+
decoratorFinishedRef.v = true;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
1807
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
1808
|
+
}
|
|
1809
|
+
function assertCallable(fn, hint) {
|
|
1810
|
+
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
1811
|
+
}
|
|
1812
|
+
function assertValidReturnValue(kind, value) {
|
|
1813
|
+
var type = typeof value;
|
|
1814
|
+
if (kind === 1) {
|
|
1815
|
+
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1816
|
+
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
1817
|
+
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
1818
|
+
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
1819
|
+
} else if (type !== "function") {
|
|
1820
|
+
var hint;
|
|
1821
|
+
if (kind === 0) hint = "field";
|
|
1822
|
+
else if (kind === 10) hint = "class";
|
|
1823
|
+
else hint = "method";
|
|
1824
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
1828
|
+
var decs = decInfo[0];
|
|
1829
|
+
var desc, init, value;
|
|
1830
|
+
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
1831
|
+
get: decInfo[3],
|
|
1832
|
+
set: decInfo[4]
|
|
1833
|
+
};
|
|
1834
|
+
else if (kind === 3) desc = { get: decInfo[3] };
|
|
1835
|
+
else if (kind === 4) desc = { set: decInfo[3] };
|
|
1836
|
+
else desc = { value: decInfo[3] };
|
|
1837
|
+
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
1838
|
+
if (kind === 1) value = {
|
|
1839
|
+
get: desc.get,
|
|
1840
|
+
set: desc.set
|
|
1841
|
+
};
|
|
1842
|
+
else if (kind === 2) value = desc.value;
|
|
1843
|
+
else if (kind === 3) value = desc.get;
|
|
1844
|
+
else if (kind === 4) value = desc.set;
|
|
1845
|
+
var newValue, get, set;
|
|
1846
|
+
if (typeof decs === "function") {
|
|
1847
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
1848
|
+
if (newValue !== void 0) {
|
|
1849
|
+
assertValidReturnValue(kind, newValue);
|
|
1850
|
+
if (kind === 0) init = newValue;
|
|
1851
|
+
else if (kind === 1) {
|
|
1852
|
+
init = newValue.init;
|
|
1853
|
+
get = newValue.get || value.get;
|
|
1854
|
+
set = newValue.set || value.set;
|
|
1855
|
+
value = {
|
|
1856
|
+
get,
|
|
1857
|
+
set
|
|
1858
|
+
};
|
|
1859
|
+
} else value = newValue;
|
|
1860
|
+
}
|
|
1861
|
+
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
1862
|
+
var dec = decs[i];
|
|
1863
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
1864
|
+
if (newValue !== void 0) {
|
|
1865
|
+
assertValidReturnValue(kind, newValue);
|
|
1866
|
+
var newInit;
|
|
1867
|
+
if (kind === 0) newInit = newValue;
|
|
1868
|
+
else if (kind === 1) {
|
|
1869
|
+
newInit = newValue.init;
|
|
1870
|
+
get = newValue.get || value.get;
|
|
1871
|
+
set = newValue.set || value.set;
|
|
1872
|
+
value = {
|
|
1873
|
+
get,
|
|
1874
|
+
set
|
|
1875
|
+
};
|
|
1876
|
+
} else value = newValue;
|
|
1877
|
+
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
1878
|
+
else if (typeof init === "function") init = [init, newInit];
|
|
1879
|
+
else init.push(newInit);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
if (kind === 0 || kind === 1) {
|
|
1883
|
+
if (init === void 0) init = function(instance, init$1) {
|
|
1884
|
+
return init$1;
|
|
1885
|
+
};
|
|
1886
|
+
else if (typeof init !== "function") {
|
|
1887
|
+
var ownInitializers = init;
|
|
1888
|
+
init = function(instance, init$1) {
|
|
1889
|
+
var value$1 = init$1;
|
|
1890
|
+
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
1891
|
+
return value$1;
|
|
1892
|
+
};
|
|
1893
|
+
} else {
|
|
1894
|
+
var originalInitializer = init;
|
|
1895
|
+
init = function(instance, init$1) {
|
|
1896
|
+
return originalInitializer.call(instance, init$1);
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
ret.push(init);
|
|
1900
|
+
}
|
|
1901
|
+
if (kind !== 0) {
|
|
1902
|
+
if (kind === 1) {
|
|
1903
|
+
desc.get = value.get;
|
|
1904
|
+
desc.set = value.set;
|
|
1905
|
+
} else if (kind === 2) desc.value = value;
|
|
1906
|
+
else if (kind === 3) desc.get = value;
|
|
1907
|
+
else if (kind === 4) desc.set = value;
|
|
1908
|
+
if (isPrivate) if (kind === 1) {
|
|
1909
|
+
ret.push(function(instance, args) {
|
|
1910
|
+
return value.get.call(instance, args);
|
|
1911
|
+
});
|
|
1912
|
+
ret.push(function(instance, args) {
|
|
1913
|
+
return value.set.call(instance, args);
|
|
1914
|
+
});
|
|
1915
|
+
} else if (kind === 2) ret.push(value);
|
|
1916
|
+
else ret.push(function(instance, args) {
|
|
1917
|
+
return value.call(instance, args);
|
|
1918
|
+
});
|
|
1919
|
+
else Object.defineProperty(base, name, desc);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
1923
|
+
var ret = [];
|
|
1924
|
+
var protoInitializers;
|
|
1925
|
+
var staticInitializers;
|
|
1926
|
+
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
1927
|
+
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
1928
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
1929
|
+
var decInfo = decInfos[i];
|
|
1930
|
+
if (!Array.isArray(decInfo)) continue;
|
|
1931
|
+
var kind = decInfo[1];
|
|
1932
|
+
var name = decInfo[2];
|
|
1933
|
+
var isPrivate = decInfo.length > 3;
|
|
1934
|
+
var isStatic = kind >= 5;
|
|
1935
|
+
var base;
|
|
1936
|
+
var initializers;
|
|
1937
|
+
if (isStatic) {
|
|
1938
|
+
base = Class;
|
|
1939
|
+
kind = kind - 5;
|
|
1940
|
+
staticInitializers = staticInitializers || [];
|
|
1941
|
+
initializers = staticInitializers;
|
|
1942
|
+
} else {
|
|
1943
|
+
base = Class.prototype;
|
|
1944
|
+
protoInitializers = protoInitializers || [];
|
|
1945
|
+
initializers = protoInitializers;
|
|
1946
|
+
}
|
|
1947
|
+
if (kind !== 0 && !isPrivate) {
|
|
1948
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
1949
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
1950
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
1951
|
+
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
1952
|
+
else existingNonFields.set(name, true);
|
|
1953
|
+
}
|
|
1954
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
1955
|
+
}
|
|
1956
|
+
pushInitializers(ret, protoInitializers);
|
|
1957
|
+
pushInitializers(ret, staticInitializers);
|
|
1958
|
+
return ret;
|
|
1959
|
+
}
|
|
1960
|
+
function pushInitializers(ret, initializers) {
|
|
1961
|
+
if (initializers) ret.push(function(instance) {
|
|
1962
|
+
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
1963
|
+
return instance;
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
1967
|
+
if (classDecs.length > 0) {
|
|
1968
|
+
var initializers = [];
|
|
1969
|
+
var newClass = targetClass;
|
|
1970
|
+
var name = targetClass.name;
|
|
1971
|
+
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
1972
|
+
var decoratorFinishedRef = { v: false };
|
|
1973
|
+
try {
|
|
1974
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
1975
|
+
kind: "class",
|
|
1976
|
+
name,
|
|
1977
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
1978
|
+
metadata
|
|
1979
|
+
});
|
|
1980
|
+
} finally {
|
|
1981
|
+
decoratorFinishedRef.v = true;
|
|
1982
|
+
}
|
|
1983
|
+
if (nextNewClass !== void 0) {
|
|
1984
|
+
assertValidReturnValue(10, nextNewClass);
|
|
1985
|
+
newClass = nextNewClass;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
return [defineMetadata(newClass, metadata), function() {
|
|
1989
|
+
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
1990
|
+
}];
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function defineMetadata(Class, metadata) {
|
|
1994
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
1995
|
+
configurable: true,
|
|
1996
|
+
enumerable: true,
|
|
1997
|
+
value: metadata
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
2001
|
+
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
2002
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
2003
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
2004
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
2005
|
+
return {
|
|
2006
|
+
e,
|
|
2007
|
+
get c() {
|
|
2008
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
function _apply_decs_2203_r$11(targetClass, memberDecs, classDecs, parentClass) {
|
|
2014
|
+
return (_apply_decs_2203_r$11 = applyDecs2203RFactory$11())(targetClass, memberDecs, classDecs, parentClass);
|
|
2015
|
+
}
|
|
2016
|
+
var _dec$11, _initClass$11;
|
|
2017
|
+
let _InstanceResolverService;
|
|
2018
|
+
_dec$11 = (0, _navios_di.Injectable)();
|
|
2019
|
+
var InstanceResolverService = class {
|
|
2020
|
+
static {
|
|
2021
|
+
({c: [_InstanceResolverService, _initClass$11]} = _apply_decs_2203_r$11(this, [], [_dec$11]));
|
|
2022
|
+
}
|
|
2023
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
2024
|
+
/**
|
|
2025
|
+
* Attempts to resolve a class instance, automatically detecting if it needs
|
|
2026
|
+
* request scope based on its dependencies.
|
|
2027
|
+
*
|
|
2028
|
+
* @param classType - The class to resolve
|
|
2029
|
+
* @returns A resolution result containing either a cached instance or resolver function
|
|
2030
|
+
*/ async resolve(classType) {
|
|
2031
|
+
let cachedInstance = null;
|
|
2032
|
+
try {
|
|
2033
|
+
cachedInstance = await this.container.get(classType);
|
|
2034
|
+
} catch {
|
|
2035
|
+
const token = (0, _navios_di.getInjectableToken)(classType);
|
|
2036
|
+
this.container.getRegistry().updateScope(token, _navios_di.InjectableScope.Request);
|
|
2037
|
+
}
|
|
2038
|
+
return {
|
|
2039
|
+
cached: cachedInstance !== null,
|
|
2040
|
+
instance: cachedInstance,
|
|
2041
|
+
resolve: (scoped) => scoped.get(classType)
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
/**
|
|
2045
|
+
* Attempts to resolve multiple class instances, automatically detecting if any need
|
|
2046
|
+
* request scope based on their dependencies.
|
|
2047
|
+
*
|
|
2048
|
+
* Returns `cached: true` only if ALL classes can be resolved as singletons.
|
|
2049
|
+
* If any class has request-scoped dependencies, returns `cached: false`.
|
|
2050
|
+
*
|
|
2051
|
+
* @param classTypes - The classes to resolve
|
|
2052
|
+
* @returns A resolution result containing either all cached instances or resolver function
|
|
2053
|
+
*/ async resolveMany(classTypes) {
|
|
2054
|
+
if (classTypes.length === 0) return {
|
|
2055
|
+
cached: true,
|
|
2056
|
+
instances: [],
|
|
2057
|
+
classTypes: [],
|
|
2058
|
+
resolve: async () => []
|
|
2059
|
+
};
|
|
2060
|
+
const results = await Promise.all(classTypes.map(async (classType) => {
|
|
2061
|
+
try {
|
|
2062
|
+
return {
|
|
2063
|
+
success: true,
|
|
2064
|
+
instance: await this.container.get(classType)
|
|
2065
|
+
};
|
|
2066
|
+
} catch {
|
|
2067
|
+
const token = (0, _navios_di.getInjectableToken)(classType);
|
|
2068
|
+
this.container.getRegistry().updateScope(token, _navios_di.InjectableScope.Request);
|
|
2069
|
+
return {
|
|
2070
|
+
success: false,
|
|
2071
|
+
instance: null
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
}));
|
|
2075
|
+
const allCached = results.every((r) => r.success);
|
|
2076
|
+
return {
|
|
2077
|
+
cached: allCached,
|
|
2078
|
+
instances: allCached ? results.map((r) => r.instance) : null,
|
|
2079
|
+
classTypes,
|
|
2080
|
+
resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
static {
|
|
2084
|
+
_initClass$11();
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
/**
|
|
2088
|
+
* @deprecated Use InstanceResolverService instead
|
|
2089
|
+
*/ const ControllerResolverService = _InstanceResolverService;
|
|
2090
|
+
|
|
1708
2091
|
//#endregion
|
|
1709
2092
|
//#region src/services/guard-runner.service.mts
|
|
1710
2093
|
function applyDecs2203RFactory$10() {
|
|
@@ -1986,29 +2369,46 @@ function _apply_decs_2203_r$10(targetClass, memberDecs, classDecs, parentClass)
|
|
|
1986
2369
|
}
|
|
1987
2370
|
var _dec$10, _initClass$10;
|
|
1988
2371
|
let _GuardRunnerService;
|
|
1989
|
-
_dec$10 = (0,
|
|
2372
|
+
_dec$10 = (0, _navios_di.Injectable)();
|
|
1990
2373
|
var GuardRunnerService = class {
|
|
1991
2374
|
static {
|
|
1992
2375
|
({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
|
|
1993
2376
|
}
|
|
1994
|
-
logger = (0,
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2377
|
+
logger = (0, _navios_di.inject)(Logger, { context: _GuardRunnerService.name });
|
|
2378
|
+
/**
|
|
2379
|
+
* Runs guards that need to be resolved from a scoped container.
|
|
2380
|
+
* Use this when guards have request-scoped dependencies.
|
|
2381
|
+
*/ async runGuards(allGuards, executionContext, context) {
|
|
2382
|
+
const guardsArray = Array.from(allGuards).reverse();
|
|
2383
|
+
const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
|
|
1998
2384
|
const guardInstance = await context.get(guard);
|
|
1999
2385
|
if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2386
|
+
return guardInstance;
|
|
2387
|
+
}));
|
|
2388
|
+
return this.executeGuards(guardInstances, executionContext);
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Runs pre-resolved guard instances.
|
|
2392
|
+
* Use this when all guards are singletons and have been pre-resolved at startup.
|
|
2393
|
+
*/ async runGuardsStatic(guardInstances, executionContext) {
|
|
2394
|
+
return this.executeGuards(guardInstances, executionContext);
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* Shared guard execution logic.
|
|
2398
|
+
* Iterates through guard instances and calls canActivate on each.
|
|
2399
|
+
*/ async executeGuards(guardInstances, executionContext) {
|
|
2400
|
+
let canActivate = true;
|
|
2401
|
+
for (const guardInstance of guardInstances) try {
|
|
2402
|
+
canActivate = await guardInstance.canActivate(executionContext);
|
|
2403
|
+
if (!canActivate) break;
|
|
2404
|
+
} catch (error) {
|
|
2405
|
+
if (error instanceof HttpException) {
|
|
2406
|
+
executionContext.getReply().status(error.statusCode).send(error.response);
|
|
2407
|
+
return false;
|
|
2408
|
+
} else {
|
|
2409
|
+
this.logger.error("Error running guard", error);
|
|
2410
|
+
executionContext.getReply().status(500).send({ message: "Internal server error" });
|
|
2411
|
+
return false;
|
|
2012
2412
|
}
|
|
2013
2413
|
}
|
|
2014
2414
|
if (!canActivate) {
|
|
@@ -2313,13 +2713,13 @@ function _apply_decs_2203_r$9(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
2313
2713
|
}
|
|
2314
2714
|
var _dec$9, _initClass$9;
|
|
2315
2715
|
let _ModuleLoaderService;
|
|
2316
|
-
_dec$9 = (0,
|
|
2716
|
+
_dec$9 = (0, _navios_di.Injectable)();
|
|
2317
2717
|
var ModuleLoaderService = class {
|
|
2318
2718
|
static {
|
|
2319
2719
|
({c: [_ModuleLoaderService, _initClass$9]} = _apply_decs_2203_r$9(this, [], [_dec$9]));
|
|
2320
2720
|
}
|
|
2321
|
-
logger = (0,
|
|
2322
|
-
container = (0,
|
|
2721
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ModuleLoaderService.name });
|
|
2722
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
2323
2723
|
modulesMetadata = /* @__PURE__ */ new Map();
|
|
2324
2724
|
loadedModules = /* @__PURE__ */ new Map();
|
|
2325
2725
|
initialized = false;
|
|
@@ -2328,6 +2728,49 @@ var ModuleLoaderService = class {
|
|
|
2328
2728
|
await this.traverseModules(appModule);
|
|
2329
2729
|
this.initialized = true;
|
|
2330
2730
|
}
|
|
2731
|
+
/**
|
|
2732
|
+
* Extends the module tree with additional modules or controllers.
|
|
2733
|
+
*
|
|
2734
|
+
* This method is designed to be called by plugins during registration,
|
|
2735
|
+
* which happens after initial module loading but before route registration.
|
|
2736
|
+
*
|
|
2737
|
+
* @param extensions - Array of module extensions to add
|
|
2738
|
+
* @throws Error if not initialized (loadModules must be called first)
|
|
2739
|
+
*
|
|
2740
|
+
* @example
|
|
2741
|
+
* ```typescript
|
|
2742
|
+
* // In plugin registration
|
|
2743
|
+
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
2744
|
+
* await moduleLoader.extendModules([{
|
|
2745
|
+
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
2746
|
+
* moduleName: 'OpenApiBunModule',
|
|
2747
|
+
* }])
|
|
2748
|
+
* ```
|
|
2749
|
+
*/ async extendModules(extensions) {
|
|
2750
|
+
if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
|
|
2751
|
+
for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
|
|
2752
|
+
else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
|
|
2753
|
+
else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
|
|
2754
|
+
}
|
|
2755
|
+
/**
|
|
2756
|
+
* Registers controllers under a synthetic module.
|
|
2757
|
+
* Used when plugins want to add controllers without a full module class.
|
|
2758
|
+
*/ async registerControllers(controllers, moduleName) {
|
|
2759
|
+
if (this.modulesMetadata.has(moduleName)) {
|
|
2760
|
+
const existing = this.modulesMetadata.get(moduleName);
|
|
2761
|
+
for (const controller of controllers) existing.controllers.add(controller);
|
|
2762
|
+
this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
|
|
2763
|
+
} else {
|
|
2764
|
+
const metadata = {
|
|
2765
|
+
controllers: new Set(controllers),
|
|
2766
|
+
imports: /* @__PURE__ */ new Set(),
|
|
2767
|
+
guards: /* @__PURE__ */ new Set(),
|
|
2768
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
2769
|
+
};
|
|
2770
|
+
this.modulesMetadata.set(moduleName, metadata);
|
|
2771
|
+
this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2331
2774
|
async traverseModules(module$1, parentMetadata) {
|
|
2332
2775
|
const metadata = require_use_guards_decorator.extractModuleMetadata(module$1);
|
|
2333
2776
|
if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
|
|
@@ -2727,7 +3170,7 @@ function _apply_decs_2203_r$8(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
2727
3170
|
}
|
|
2728
3171
|
var _dec$8, _initClass$8;
|
|
2729
3172
|
let _NaviosEnvironment;
|
|
2730
|
-
_dec$8 = (0,
|
|
3173
|
+
_dec$8 = (0, _navios_di.Injectable)();
|
|
2731
3174
|
var NaviosEnvironment = class {
|
|
2732
3175
|
static {
|
|
2733
3176
|
({c: [_NaviosEnvironment, _initClass$8]} = _apply_decs_2203_r$8(this, [], [_dec$8]));
|
|
@@ -3028,12 +3471,12 @@ function _apply_decs_2203_r$7(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3028
3471
|
}
|
|
3029
3472
|
var _dec$7, _initClass$7;
|
|
3030
3473
|
let _EndpointAdapterFactory;
|
|
3031
|
-
_dec$7 = (0,
|
|
3474
|
+
_dec$7 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.EndpointAdapterToken });
|
|
3032
3475
|
var EndpointAdapterFactory = class {
|
|
3033
3476
|
static {
|
|
3034
3477
|
({c: [_EndpointAdapterFactory, _initClass$7]} = _apply_decs_2203_r$7(this, [], [_dec$7]));
|
|
3035
3478
|
}
|
|
3036
|
-
environment = (0,
|
|
3479
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3037
3480
|
create(ctx) {
|
|
3038
3481
|
const service = this.environment.getHttpToken(require_use_guards_decorator.EndpointAdapterToken);
|
|
3039
3482
|
if (!service) throw new Error("EndpointAdapterToken service not found in environment");
|
|
@@ -3325,12 +3768,12 @@ function _apply_decs_2203_r$6(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3325
3768
|
}
|
|
3326
3769
|
var _dec$6, _initClass$6;
|
|
3327
3770
|
let _HttpAdapterFactory;
|
|
3328
|
-
_dec$6 = (0,
|
|
3771
|
+
_dec$6 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.HttpAdapterToken });
|
|
3329
3772
|
var HttpAdapterFactory = class {
|
|
3330
3773
|
static {
|
|
3331
3774
|
({c: [_HttpAdapterFactory, _initClass$6]} = _apply_decs_2203_r$6(this, [], [_dec$6]));
|
|
3332
3775
|
}
|
|
3333
|
-
environment = (0,
|
|
3776
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3334
3777
|
create(ctx) {
|
|
3335
3778
|
const service = this.environment.getHttpToken(require_use_guards_decorator.HttpAdapterToken);
|
|
3336
3779
|
if (!service) throw new Error("HttpAdapterToken service not found in environment");
|
|
@@ -3622,12 +4065,12 @@ function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3622
4065
|
}
|
|
3623
4066
|
var _dec$5, _initClass$5;
|
|
3624
4067
|
let _MultipartAdapterFactory;
|
|
3625
|
-
_dec$5 = (0,
|
|
4068
|
+
_dec$5 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.MultipartAdapterToken });
|
|
3626
4069
|
var MultipartAdapterFactory = class {
|
|
3627
4070
|
static {
|
|
3628
4071
|
({c: [_MultipartAdapterFactory, _initClass$5]} = _apply_decs_2203_r$5(this, [], [_dec$5]));
|
|
3629
4072
|
}
|
|
3630
|
-
environment = (0,
|
|
4073
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3631
4074
|
create(ctx) {
|
|
3632
4075
|
const service = this.environment.getHttpToken(require_use_guards_decorator.MultipartAdapterToken);
|
|
3633
4076
|
if (!service) throw new Error("MultipartAdapterToken service not found in environment");
|
|
@@ -3919,15 +4362,15 @@ function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3919
4362
|
}
|
|
3920
4363
|
var _dec$4, _initClass$4;
|
|
3921
4364
|
let _RequestFactory;
|
|
3922
|
-
_dec$4 = (0,
|
|
4365
|
+
_dec$4 = (0, _navios_di.Factory)({
|
|
3923
4366
|
token: require_use_guards_decorator.Request,
|
|
3924
|
-
scope:
|
|
4367
|
+
scope: _navios_di.InjectableScope.Request
|
|
3925
4368
|
});
|
|
3926
4369
|
var RequestFactory = class {
|
|
3927
4370
|
static {
|
|
3928
4371
|
({c: [_RequestFactory, _initClass$4]} = _apply_decs_2203_r$4(this, [], [_dec$4]));
|
|
3929
4372
|
}
|
|
3930
|
-
environment = (0,
|
|
4373
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3931
4374
|
create(ctx) {
|
|
3932
4375
|
const service = this.environment.getHttpToken(require_use_guards_decorator.Request);
|
|
3933
4376
|
if (!service) throw new Error("RequestToken service not found in environment");
|
|
@@ -4219,15 +4662,15 @@ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4219
4662
|
}
|
|
4220
4663
|
var _dec$3, _initClass$3;
|
|
4221
4664
|
let _ReplyFactory;
|
|
4222
|
-
_dec$3 = (0,
|
|
4665
|
+
_dec$3 = (0, _navios_di.Factory)({
|
|
4223
4666
|
token: require_use_guards_decorator.Reply,
|
|
4224
|
-
scope:
|
|
4667
|
+
scope: _navios_di.InjectableScope.Request
|
|
4225
4668
|
});
|
|
4226
4669
|
var ReplyFactory = class {
|
|
4227
4670
|
static {
|
|
4228
4671
|
({c: [_ReplyFactory, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
|
|
4229
4672
|
}
|
|
4230
|
-
environment = (0,
|
|
4673
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4231
4674
|
create(ctx) {
|
|
4232
4675
|
const service = this.environment.getHttpToken(require_use_guards_decorator.Reply);
|
|
4233
4676
|
if (!service) throw new Error("ReplyToken service not found in environment");
|
|
@@ -4519,12 +4962,12 @@ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4519
4962
|
}
|
|
4520
4963
|
var _dec$2, _initClass$2;
|
|
4521
4964
|
let _StreamAdapterFactory;
|
|
4522
|
-
_dec$2 = (0,
|
|
4965
|
+
_dec$2 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.StreamAdapterToken });
|
|
4523
4966
|
var StreamAdapterFactory = class {
|
|
4524
4967
|
static {
|
|
4525
4968
|
({c: [_StreamAdapterFactory, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
|
|
4526
4969
|
}
|
|
4527
|
-
environment = (0,
|
|
4970
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4528
4971
|
create(ctx) {
|
|
4529
4972
|
const service = this.environment.getHttpToken(require_use_guards_decorator.StreamAdapterToken);
|
|
4530
4973
|
if (!service) throw new Error("StreamAdapterToken service not found in environment");
|
|
@@ -4816,12 +5259,12 @@ function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4816
5259
|
}
|
|
4817
5260
|
var _dec$1, _initClass$1;
|
|
4818
5261
|
let _XmlStreamAdapterFactory;
|
|
4819
|
-
_dec$1 = (0,
|
|
5262
|
+
_dec$1 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.XmlStreamAdapterToken });
|
|
4820
5263
|
var XmlStreamAdapterFactory = class {
|
|
4821
5264
|
static {
|
|
4822
5265
|
({c: [_XmlStreamAdapterFactory, _initClass$1]} = _apply_decs_2203_r$1(this, [], [_dec$1]));
|
|
4823
5266
|
}
|
|
4824
|
-
environment = (0,
|
|
5267
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4825
5268
|
create(ctx) {
|
|
4826
5269
|
const service = this.environment.getHttpToken(require_use_guards_decorator.XmlStreamAdapterToken);
|
|
4827
5270
|
if (!service) throw new Error("XmlStreamAdapterToken service not found in environment");
|
|
@@ -5113,18 +5556,19 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
5113
5556
|
}
|
|
5114
5557
|
var _dec, _initClass;
|
|
5115
5558
|
let _NaviosApplication;
|
|
5116
|
-
_dec = (0,
|
|
5559
|
+
_dec = (0, _navios_di.Injectable)();
|
|
5117
5560
|
var NaviosApplication = class {
|
|
5118
5561
|
static {
|
|
5119
5562
|
({c: [_NaviosApplication, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
|
|
5120
5563
|
}
|
|
5121
|
-
environment = (0,
|
|
5122
|
-
moduleLoader = (0,
|
|
5564
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
5565
|
+
moduleLoader = (0, _navios_di.inject)(_ModuleLoaderService);
|
|
5123
5566
|
httpApplication = null;
|
|
5124
|
-
logger = (0,
|
|
5125
|
-
container = (0,
|
|
5567
|
+
logger = (0, _navios_di.inject)(Logger, { context: _NaviosApplication.name });
|
|
5568
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
5126
5569
|
appModule = null;
|
|
5127
5570
|
options = { adapter: [] };
|
|
5571
|
+
plugins = [];
|
|
5128
5572
|
/**
|
|
5129
5573
|
* Indicates whether the application has been initialized.
|
|
5130
5574
|
* Set to `true` after `init()` completes successfully.
|
|
@@ -5132,7 +5576,7 @@ var NaviosApplication = class {
|
|
|
5132
5576
|
/**
|
|
5133
5577
|
* Sets up the application with the provided module and options.
|
|
5134
5578
|
* This is called automatically by NaviosFactory.create().
|
|
5135
|
-
*
|
|
5579
|
+
*
|
|
5136
5580
|
* @param appModule - The root application module
|
|
5137
5581
|
* @param options - Application configuration options
|
|
5138
5582
|
* @internal
|
|
@@ -5143,24 +5587,46 @@ var NaviosApplication = class {
|
|
|
5143
5587
|
}
|
|
5144
5588
|
/**
|
|
5145
5589
|
* Gets the dependency injection container used by this application.
|
|
5146
|
-
*
|
|
5590
|
+
*
|
|
5147
5591
|
* @returns The Container instance
|
|
5148
5592
|
*/ getContainer() {
|
|
5149
5593
|
return this.container;
|
|
5150
5594
|
}
|
|
5151
5595
|
/**
|
|
5596
|
+
* Registers a plugin to be initialized after modules are loaded.
|
|
5597
|
+
*
|
|
5598
|
+
* Plugins are initialized in the order they are registered,
|
|
5599
|
+
* after all modules are loaded but before the server starts listening.
|
|
5600
|
+
*
|
|
5601
|
+
* @param definition - Plugin definition with options
|
|
5602
|
+
* @returns this for method chaining
|
|
5603
|
+
*
|
|
5604
|
+
* @example
|
|
5605
|
+
* ```typescript
|
|
5606
|
+
* import { defineOpenApiPlugin } from '@navios/openapi-fastify'
|
|
5607
|
+
*
|
|
5608
|
+
* app.usePlugin(defineOpenApiPlugin({
|
|
5609
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
5610
|
+
* }))
|
|
5611
|
+
* ```
|
|
5612
|
+
*/ usePlugin(definition) {
|
|
5613
|
+
this.plugins.push(definition);
|
|
5614
|
+
return this;
|
|
5615
|
+
}
|
|
5616
|
+
/**
|
|
5152
5617
|
* Initializes the application.
|
|
5153
|
-
*
|
|
5618
|
+
*
|
|
5154
5619
|
* This method:
|
|
5155
5620
|
* - Loads all modules and their dependencies
|
|
5156
5621
|
* - Sets up the HTTP server if an adapter is configured
|
|
5157
5622
|
* - Calls onModuleInit hooks on all modules
|
|
5623
|
+
* - Initializes registered plugins
|
|
5158
5624
|
* - Marks the application as initialized
|
|
5159
|
-
*
|
|
5625
|
+
*
|
|
5160
5626
|
* Must be called before `listen()`.
|
|
5161
|
-
*
|
|
5627
|
+
*
|
|
5162
5628
|
* @throws Error if app module is not set
|
|
5163
|
-
*
|
|
5629
|
+
*
|
|
5164
5630
|
* @example
|
|
5165
5631
|
* ```typescript
|
|
5166
5632
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5173,6 +5639,7 @@ var NaviosApplication = class {
|
|
|
5173
5639
|
if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
|
|
5174
5640
|
await this.moduleLoader.loadModules(this.appModule);
|
|
5175
5641
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
|
|
5642
|
+
await this.initPlugins();
|
|
5176
5643
|
await this.initModules();
|
|
5177
5644
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
|
|
5178
5645
|
this.isInitialized = true;
|
|
@@ -5182,12 +5649,30 @@ var NaviosApplication = class {
|
|
|
5182
5649
|
const modules = this.moduleLoader.getAllModules();
|
|
5183
5650
|
await this.httpApplication?.onModulesInit(modules);
|
|
5184
5651
|
}
|
|
5652
|
+
async initPlugins() {
|
|
5653
|
+
if (this.plugins.length === 0) return;
|
|
5654
|
+
let server = null;
|
|
5655
|
+
try {
|
|
5656
|
+
server = this.httpApplication?.getServer() ?? null;
|
|
5657
|
+
} catch {}
|
|
5658
|
+
const context = {
|
|
5659
|
+
modules: this.moduleLoader.getAllModules(),
|
|
5660
|
+
server,
|
|
5661
|
+
container: this.container,
|
|
5662
|
+
globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
|
|
5663
|
+
moduleLoader: this.moduleLoader
|
|
5664
|
+
};
|
|
5665
|
+
for (const { plugin, options } of this.plugins) {
|
|
5666
|
+
this.logger.debug(`Initializing plugin: ${plugin.name}`);
|
|
5667
|
+
await plugin.register(context, options);
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5185
5670
|
/**
|
|
5186
5671
|
* Enables CORS (Cross-Origin Resource Sharing) for the application.
|
|
5187
|
-
*
|
|
5672
|
+
*
|
|
5188
5673
|
* @param options - CORS configuration options (adapter-specific)
|
|
5189
5674
|
* @throws Error if HTTP application is not set
|
|
5190
|
-
*
|
|
5675
|
+
*
|
|
5191
5676
|
* @example
|
|
5192
5677
|
* ```typescript
|
|
5193
5678
|
* app.enableCors({
|
|
@@ -5202,10 +5687,10 @@ var NaviosApplication = class {
|
|
|
5202
5687
|
}
|
|
5203
5688
|
/**
|
|
5204
5689
|
* Enables multipart/form-data support for file uploads.
|
|
5205
|
-
*
|
|
5690
|
+
*
|
|
5206
5691
|
* @param options - Multipart configuration options (adapter-specific)
|
|
5207
5692
|
* @throws Error if HTTP application is not set
|
|
5208
|
-
*
|
|
5693
|
+
*
|
|
5209
5694
|
* @example
|
|
5210
5695
|
* ```typescript
|
|
5211
5696
|
* app.enableMultipart({
|
|
@@ -5220,10 +5705,10 @@ var NaviosApplication = class {
|
|
|
5220
5705
|
}
|
|
5221
5706
|
/**
|
|
5222
5707
|
* Sets a global prefix for all routes.
|
|
5223
|
-
*
|
|
5708
|
+
*
|
|
5224
5709
|
* @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
|
|
5225
5710
|
* @throws Error if HTTP application is not set
|
|
5226
|
-
*
|
|
5711
|
+
*
|
|
5227
5712
|
* @example
|
|
5228
5713
|
* ```typescript
|
|
5229
5714
|
* app.setGlobalPrefix('/api/v1')
|
|
@@ -5235,14 +5720,14 @@ var NaviosApplication = class {
|
|
|
5235
5720
|
}
|
|
5236
5721
|
/**
|
|
5237
5722
|
* Gets the underlying HTTP server instance.
|
|
5238
|
-
*
|
|
5723
|
+
*
|
|
5239
5724
|
* The type of the returned server depends on the adapter used:
|
|
5240
5725
|
* - Fastify adapter: Returns FastifyInstance
|
|
5241
5726
|
* - Bun adapter: Returns Bun.Server
|
|
5242
|
-
*
|
|
5727
|
+
*
|
|
5243
5728
|
* @returns The HTTP server instance
|
|
5244
5729
|
* @throws Error if HTTP application is not set
|
|
5245
|
-
*
|
|
5730
|
+
*
|
|
5246
5731
|
* @example
|
|
5247
5732
|
* ```typescript
|
|
5248
5733
|
* const server = app.getServer()
|
|
@@ -5254,10 +5739,10 @@ var NaviosApplication = class {
|
|
|
5254
5739
|
}
|
|
5255
5740
|
/**
|
|
5256
5741
|
* Starts the HTTP server and begins listening for requests.
|
|
5257
|
-
*
|
|
5742
|
+
*
|
|
5258
5743
|
* @param options - Listen options (port, host, etc.)
|
|
5259
5744
|
* @throws Error if HTTP application is not set
|
|
5260
|
-
*
|
|
5745
|
+
*
|
|
5261
5746
|
* @example
|
|
5262
5747
|
* ```typescript
|
|
5263
5748
|
* await app.listen({ port: 3000, host: '0.0.0.0' })
|
|
@@ -5268,7 +5753,7 @@ var NaviosApplication = class {
|
|
|
5268
5753
|
}
|
|
5269
5754
|
/**
|
|
5270
5755
|
* Disposes of application resources.
|
|
5271
|
-
*
|
|
5756
|
+
*
|
|
5272
5757
|
* Cleans up the HTTP server and module loader.
|
|
5273
5758
|
* This method is called automatically by `close()`.
|
|
5274
5759
|
*/ async dispose() {
|
|
@@ -5277,9 +5762,9 @@ var NaviosApplication = class {
|
|
|
5277
5762
|
}
|
|
5278
5763
|
/**
|
|
5279
5764
|
* Closes the application and cleans up all resources.
|
|
5280
|
-
*
|
|
5765
|
+
*
|
|
5281
5766
|
* This is an alias for `dispose()`.
|
|
5282
|
-
*
|
|
5767
|
+
*
|
|
5283
5768
|
* @example
|
|
5284
5769
|
* ```typescript
|
|
5285
5770
|
* // Graceful shutdown
|
|
@@ -5300,31 +5785,31 @@ var NaviosApplication = class {
|
|
|
5300
5785
|
//#region src/navios.factory.mts
|
|
5301
5786
|
/**
|
|
5302
5787
|
* Factory class for creating and configuring Navios applications.
|
|
5303
|
-
*
|
|
5788
|
+
*
|
|
5304
5789
|
* This is the main entry point for bootstrapping a Navios application.
|
|
5305
5790
|
* It handles dependency injection container setup, adapter registration,
|
|
5306
5791
|
* and logger configuration.
|
|
5307
|
-
*
|
|
5792
|
+
*
|
|
5308
5793
|
* @example
|
|
5309
5794
|
* ```typescript
|
|
5310
5795
|
* import { NaviosFactory } from '@navios/core'
|
|
5311
5796
|
* import { defineFastifyEnvironment } from '@navios/adapter-fastify'
|
|
5312
|
-
*
|
|
5797
|
+
*
|
|
5313
5798
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5314
5799
|
* adapter: defineFastifyEnvironment(),
|
|
5315
5800
|
* logger: ['log', 'error', 'warn'],
|
|
5316
5801
|
* })
|
|
5317
|
-
*
|
|
5802
|
+
*
|
|
5318
5803
|
* await app.init()
|
|
5319
5804
|
* await app.listen({ port: 3000 })
|
|
5320
5805
|
* ```
|
|
5321
5806
|
*/ var NaviosFactory = class {
|
|
5322
5807
|
/**
|
|
5323
5808
|
* Creates a new Navios application instance.
|
|
5324
|
-
*
|
|
5809
|
+
*
|
|
5325
5810
|
* This method sets up the dependency injection container, registers the HTTP adapter,
|
|
5326
5811
|
* configures logging, and initializes the application with the provided module.
|
|
5327
|
-
*
|
|
5812
|
+
*
|
|
5328
5813
|
* @param appModule - The root application module class decorated with @Module()
|
|
5329
5814
|
* @param options - Configuration options for the application
|
|
5330
5815
|
* @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
|
|
@@ -5334,20 +5819,20 @@ var NaviosApplication = class {
|
|
|
5334
5819
|
* - `false` to disable logging
|
|
5335
5820
|
* @param options.container - Optional custom dependency injection container (useful for testing)
|
|
5336
5821
|
* @returns A configured NaviosApplication instance ready to be initialized
|
|
5337
|
-
*
|
|
5822
|
+
*
|
|
5338
5823
|
* @example
|
|
5339
5824
|
* ```typescript
|
|
5340
5825
|
* // Basic setup with Fastify adapter
|
|
5341
5826
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5342
5827
|
* adapter: defineFastifyEnvironment(),
|
|
5343
5828
|
* })
|
|
5344
|
-
*
|
|
5829
|
+
*
|
|
5345
5830
|
* // With custom logger configuration
|
|
5346
5831
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5347
5832
|
* adapter: defineFastifyEnvironment(),
|
|
5348
5833
|
* logger: ['error', 'warn', 'log'],
|
|
5349
5834
|
* })
|
|
5350
|
-
*
|
|
5835
|
+
*
|
|
5351
5836
|
* // With custom container for testing
|
|
5352
5837
|
* const container = new Container()
|
|
5353
5838
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5356,7 +5841,9 @@ var NaviosApplication = class {
|
|
|
5356
5841
|
* })
|
|
5357
5842
|
* ```
|
|
5358
5843
|
*/ static async create(appModule, options = { adapter: [] }) {
|
|
5359
|
-
const container = options.container ?? new
|
|
5844
|
+
const container = options.container ?? new _navios_di.Container();
|
|
5845
|
+
if (options.enableRequestId === true) setRequestIdEnabled(true);
|
|
5846
|
+
container.getServiceLocator().getManager().storeCreatedHolder(require_use_guards_decorator.NaviosOptionsToken.toString(), options, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
|
|
5360
5847
|
await this.registerLoggerConfiguration(container, options);
|
|
5361
5848
|
const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
|
|
5362
5849
|
for (const adapter of adapters) await this.registerEnvironment(container, adapter);
|
|
@@ -5371,8 +5858,11 @@ var NaviosApplication = class {
|
|
|
5371
5858
|
}
|
|
5372
5859
|
static async registerLoggerConfiguration(container, options) {
|
|
5373
5860
|
const { logger } = options;
|
|
5374
|
-
if (Array.isArray(logger) || isNil(logger))
|
|
5375
|
-
|
|
5861
|
+
if (Array.isArray(logger) || isNil(logger)) {
|
|
5862
|
+
(await container.get(LoggerOutput))?.setup({ logLevels: logger });
|
|
5863
|
+
return;
|
|
5864
|
+
}
|
|
5865
|
+
if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
|
|
5376
5866
|
}
|
|
5377
5867
|
};
|
|
5378
5868
|
|
|
@@ -5413,6 +5903,12 @@ Object.defineProperty(exports, 'ConflictException', {
|
|
|
5413
5903
|
return ConflictException;
|
|
5414
5904
|
}
|
|
5415
5905
|
});
|
|
5906
|
+
Object.defineProperty(exports, 'ControllerResolverService', {
|
|
5907
|
+
enumerable: true,
|
|
5908
|
+
get: function () {
|
|
5909
|
+
return ControllerResolverService;
|
|
5910
|
+
}
|
|
5911
|
+
});
|
|
5416
5912
|
Object.defineProperty(exports, 'EnvConfigProvider', {
|
|
5417
5913
|
enumerable: true,
|
|
5418
5914
|
get: function () {
|
|
@@ -5503,6 +5999,12 @@ Object.defineProperty(exports, '_HttpAdapterFactory', {
|
|
|
5503
5999
|
return _HttpAdapterFactory;
|
|
5504
6000
|
}
|
|
5505
6001
|
});
|
|
6002
|
+
Object.defineProperty(exports, '_InstanceResolverService', {
|
|
6003
|
+
enumerable: true,
|
|
6004
|
+
get: function () {
|
|
6005
|
+
return _InstanceResolverService;
|
|
6006
|
+
}
|
|
6007
|
+
});
|
|
5506
6008
|
Object.defineProperty(exports, '_LoggerInstance', {
|
|
5507
6009
|
enumerable: true,
|
|
5508
6010
|
get: function () {
|
|
@@ -5587,6 +6089,12 @@ Object.defineProperty(exports, 'filterLogLevels', {
|
|
|
5587
6089
|
return filterLogLevels;
|
|
5588
6090
|
}
|
|
5589
6091
|
});
|
|
6092
|
+
Object.defineProperty(exports, 'generateRequestId', {
|
|
6093
|
+
enumerable: true,
|
|
6094
|
+
get: function () {
|
|
6095
|
+
return generateRequestId;
|
|
6096
|
+
}
|
|
6097
|
+
});
|
|
5590
6098
|
Object.defineProperty(exports, 'getRequestId', {
|
|
5591
6099
|
enumerable: true,
|
|
5592
6100
|
get: function () {
|
|
@@ -5683,16 +6191,16 @@ Object.defineProperty(exports, 'provideConfig', {
|
|
|
5683
6191
|
return provideConfig;
|
|
5684
6192
|
}
|
|
5685
6193
|
});
|
|
5686
|
-
Object.defineProperty(exports, '
|
|
6194
|
+
Object.defineProperty(exports, 'runWithRequestId', {
|
|
5687
6195
|
enumerable: true,
|
|
5688
6196
|
get: function () {
|
|
5689
|
-
return
|
|
6197
|
+
return runWithRequestId;
|
|
5690
6198
|
}
|
|
5691
6199
|
});
|
|
5692
|
-
Object.defineProperty(exports, '
|
|
6200
|
+
Object.defineProperty(exports, 'setRequestIdEnabled', {
|
|
5693
6201
|
enumerable: true,
|
|
5694
6202
|
get: function () {
|
|
5695
|
-
return
|
|
6203
|
+
return setRequestIdEnabled;
|
|
5696
6204
|
}
|
|
5697
6205
|
});
|
|
5698
6206
|
Object.defineProperty(exports, 'stripEndSlash', {
|
|
@@ -5707,4 +6215,4 @@ Object.defineProperty(exports, 'yellow', {
|
|
|
5707
6215
|
return yellow;
|
|
5708
6216
|
}
|
|
5709
6217
|
});
|
|
5710
|
-
//# sourceMappingURL=src-
|
|
6218
|
+
//# sourceMappingURL=src-B6eISODM.cjs.map
|