@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
|
@@ -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-B6q_N0sf.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
|
|
|
@@ -182,7 +182,7 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
182
182
|
*
|
|
183
183
|
* This token is used to provide a custom logger implementation.
|
|
184
184
|
* By default, it's bound to ConsoleLogger.
|
|
185
|
-
*/ const LoggerOutput =
|
|
185
|
+
*/ const LoggerOutput = _navios_di.InjectionToken.create("LoggerOutput");
|
|
186
186
|
/**
|
|
187
187
|
* Schema for logger options.
|
|
188
188
|
*/ const loggerOptionsSchema = zod_v4.default.object({ context: zod_v4.default.string().optional() }).optional();
|
|
@@ -196,7 +196,7 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
196
196
|
* const logger = inject(Logger, { context: 'MyService' })
|
|
197
197
|
* logger.log('Hello world') // Logs with context: [MyService]
|
|
198
198
|
* ```
|
|
199
|
-
*/ const Logger =
|
|
199
|
+
*/ const Logger = _navios_di.InjectionToken.create("Logger", loggerOptionsSchema);
|
|
200
200
|
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region src/logger/console-logger.service.mts
|
|
@@ -496,7 +496,7 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
|
496
496
|
month: "2-digit"
|
|
497
497
|
});
|
|
498
498
|
let _ConsoleLogger;
|
|
499
|
-
_dec$13 = (0,
|
|
499
|
+
_dec$13 = (0, _navios_di.Injectable)({ token: LoggerOutput });
|
|
500
500
|
var ConsoleLogger = class {
|
|
501
501
|
static {
|
|
502
502
|
({c: [_ConsoleLogger, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
|
|
@@ -1033,7 +1033,7 @@ function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass)
|
|
|
1033
1033
|
}
|
|
1034
1034
|
var _dec$12, _initClass$12;
|
|
1035
1035
|
let _LoggerInstance;
|
|
1036
|
-
_dec$12 = (0,
|
|
1036
|
+
_dec$12 = (0, _navios_di.Injectable)({ token: Logger });
|
|
1037
1037
|
var LoggerInstance = class {
|
|
1038
1038
|
static {
|
|
1039
1039
|
({c: [_LoggerInstance, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
|
|
@@ -1041,7 +1041,7 @@ var LoggerInstance = class {
|
|
|
1041
1041
|
constructor(config = {}) {
|
|
1042
1042
|
this.context = config.context;
|
|
1043
1043
|
}
|
|
1044
|
-
localInstance = (0,
|
|
1044
|
+
localInstance = (0, _navios_di.inject)(LoggerOutput);
|
|
1045
1045
|
context;
|
|
1046
1046
|
error(message, ...optionalParams) {
|
|
1047
1047
|
optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(this.context) : optionalParams;
|
|
@@ -1049,6 +1049,8 @@ var LoggerInstance = class {
|
|
|
1049
1049
|
}
|
|
1050
1050
|
log(message, ...optionalParams) {
|
|
1051
1051
|
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1052
|
+
console.log("log", message, optionalParams);
|
|
1053
|
+
console.log("localInstance", this.localInstance);
|
|
1052
1054
|
this.localInstance?.log(message, ...optionalParams);
|
|
1053
1055
|
}
|
|
1054
1056
|
warn(message, ...optionalParams) {
|
|
@@ -1357,9 +1359,9 @@ var _dec$11, _initClass$11;
|
|
|
1357
1359
|
*/ const ConfigServiceOptionsSchema = zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown());
|
|
1358
1360
|
/**
|
|
1359
1361
|
* Injection token for ConfigService.
|
|
1360
|
-
*/ const ConfigServiceToken =
|
|
1362
|
+
*/ const ConfigServiceToken = _navios_di.InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
|
|
1361
1363
|
let _ConfigService;
|
|
1362
|
-
_dec$11 = (0,
|
|
1364
|
+
_dec$11 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
|
|
1363
1365
|
var ConfigService = class {
|
|
1364
1366
|
config;
|
|
1365
1367
|
static {
|
|
@@ -1372,7 +1374,7 @@ var ConfigService = class {
|
|
|
1372
1374
|
*/ constructor(config = {}) {
|
|
1373
1375
|
this.config = config;
|
|
1374
1376
|
}
|
|
1375
|
-
logger = (0,
|
|
1377
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ConfigService.name });
|
|
1376
1378
|
/**
|
|
1377
1379
|
* Gets the entire configuration object.
|
|
1378
1380
|
*
|
|
@@ -1440,7 +1442,7 @@ var ConfigService = class {
|
|
|
1440
1442
|
if (value === null) {
|
|
1441
1443
|
const message = errorMessage || `Configuration value for key "${String(key)}" is not defined`;
|
|
1442
1444
|
this.logger.error(message);
|
|
1443
|
-
throw new
|
|
1445
|
+
throw new _navios_builder.NaviosError(message);
|
|
1444
1446
|
}
|
|
1445
1447
|
return value;
|
|
1446
1448
|
}
|
|
@@ -1476,7 +1478,7 @@ var ConfigService = class {
|
|
|
1476
1478
|
* container.bind(ConfigServiceToken).toFactory(configProvider)
|
|
1477
1479
|
* ```
|
|
1478
1480
|
*/ function provideConfig(options) {
|
|
1479
|
-
return
|
|
1481
|
+
return _navios_di.InjectionToken.factory(ConfigServiceToken, async () => options.load());
|
|
1480
1482
|
}
|
|
1481
1483
|
/**
|
|
1482
1484
|
* Pre-configured ConfigService provider that uses environment variables.
|
|
@@ -1488,7 +1490,7 @@ var ConfigService = class {
|
|
|
1488
1490
|
* // Use environment variables as configuration
|
|
1489
1491
|
* container.bind(ConfigServiceToken).toValue(EnvConfigProvider)
|
|
1490
1492
|
* ```
|
|
1491
|
-
*/ const EnvConfigProvider =
|
|
1493
|
+
*/ const EnvConfigProvider = _navios_di.InjectionToken.bound(ConfigServiceToken, { ...node_process.env });
|
|
1492
1494
|
|
|
1493
1495
|
//#endregion
|
|
1494
1496
|
//#region src/exceptions/http.exception.mts
|
|
@@ -1986,12 +1988,12 @@ function _apply_decs_2203_r$10(targetClass, memberDecs, classDecs, parentClass)
|
|
|
1986
1988
|
}
|
|
1987
1989
|
var _dec$10, _initClass$10;
|
|
1988
1990
|
let _GuardRunnerService;
|
|
1989
|
-
_dec$10 = (0,
|
|
1991
|
+
_dec$10 = (0, _navios_di.Injectable)();
|
|
1990
1992
|
var GuardRunnerService = class {
|
|
1991
1993
|
static {
|
|
1992
1994
|
({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
|
|
1993
1995
|
}
|
|
1994
|
-
logger = (0,
|
|
1996
|
+
logger = (0, _navios_di.inject)(Logger, { context: _GuardRunnerService.name });
|
|
1995
1997
|
async runGuards(allGuards, executionContext, context) {
|
|
1996
1998
|
let canActivate = true;
|
|
1997
1999
|
for (const guard of Array.from(allGuards).reverse()) {
|
|
@@ -2313,13 +2315,13 @@ function _apply_decs_2203_r$9(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
2313
2315
|
}
|
|
2314
2316
|
var _dec$9, _initClass$9;
|
|
2315
2317
|
let _ModuleLoaderService;
|
|
2316
|
-
_dec$9 = (0,
|
|
2318
|
+
_dec$9 = (0, _navios_di.Injectable)();
|
|
2317
2319
|
var ModuleLoaderService = class {
|
|
2318
2320
|
static {
|
|
2319
2321
|
({c: [_ModuleLoaderService, _initClass$9]} = _apply_decs_2203_r$9(this, [], [_dec$9]));
|
|
2320
2322
|
}
|
|
2321
|
-
logger = (0,
|
|
2322
|
-
container = (0,
|
|
2323
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ModuleLoaderService.name });
|
|
2324
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
2323
2325
|
modulesMetadata = /* @__PURE__ */ new Map();
|
|
2324
2326
|
loadedModules = /* @__PURE__ */ new Map();
|
|
2325
2327
|
initialized = false;
|
|
@@ -2328,6 +2330,49 @@ var ModuleLoaderService = class {
|
|
|
2328
2330
|
await this.traverseModules(appModule);
|
|
2329
2331
|
this.initialized = true;
|
|
2330
2332
|
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Extends the module tree with additional modules or controllers.
|
|
2335
|
+
*
|
|
2336
|
+
* This method is designed to be called by plugins during registration,
|
|
2337
|
+
* which happens after initial module loading but before route registration.
|
|
2338
|
+
*
|
|
2339
|
+
* @param extensions - Array of module extensions to add
|
|
2340
|
+
* @throws Error if not initialized (loadModules must be called first)
|
|
2341
|
+
*
|
|
2342
|
+
* @example
|
|
2343
|
+
* ```typescript
|
|
2344
|
+
* // In plugin registration
|
|
2345
|
+
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
2346
|
+
* await moduleLoader.extendModules([{
|
|
2347
|
+
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
2348
|
+
* moduleName: 'OpenApiBunModule',
|
|
2349
|
+
* }])
|
|
2350
|
+
* ```
|
|
2351
|
+
*/ async extendModules(extensions) {
|
|
2352
|
+
if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
|
|
2353
|
+
for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
|
|
2354
|
+
else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
|
|
2355
|
+
else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Registers controllers under a synthetic module.
|
|
2359
|
+
* Used when plugins want to add controllers without a full module class.
|
|
2360
|
+
*/ async registerControllers(controllers, moduleName) {
|
|
2361
|
+
if (this.modulesMetadata.has(moduleName)) {
|
|
2362
|
+
const existing = this.modulesMetadata.get(moduleName);
|
|
2363
|
+
for (const controller of controllers) existing.controllers.add(controller);
|
|
2364
|
+
this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
|
|
2365
|
+
} else {
|
|
2366
|
+
const metadata = {
|
|
2367
|
+
controllers: new Set(controllers),
|
|
2368
|
+
imports: /* @__PURE__ */ new Set(),
|
|
2369
|
+
guards: /* @__PURE__ */ new Set(),
|
|
2370
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
2371
|
+
};
|
|
2372
|
+
this.modulesMetadata.set(moduleName, metadata);
|
|
2373
|
+
this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2331
2376
|
async traverseModules(module$1, parentMetadata) {
|
|
2332
2377
|
const metadata = require_use_guards_decorator.extractModuleMetadata(module$1);
|
|
2333
2378
|
if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
|
|
@@ -2727,7 +2772,7 @@ function _apply_decs_2203_r$8(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
2727
2772
|
}
|
|
2728
2773
|
var _dec$8, _initClass$8;
|
|
2729
2774
|
let _NaviosEnvironment;
|
|
2730
|
-
_dec$8 = (0,
|
|
2775
|
+
_dec$8 = (0, _navios_di.Injectable)();
|
|
2731
2776
|
var NaviosEnvironment = class {
|
|
2732
2777
|
static {
|
|
2733
2778
|
({c: [_NaviosEnvironment, _initClass$8]} = _apply_decs_2203_r$8(this, [], [_dec$8]));
|
|
@@ -3028,12 +3073,12 @@ function _apply_decs_2203_r$7(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3028
3073
|
}
|
|
3029
3074
|
var _dec$7, _initClass$7;
|
|
3030
3075
|
let _EndpointAdapterFactory;
|
|
3031
|
-
_dec$7 = (0,
|
|
3076
|
+
_dec$7 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.EndpointAdapterToken });
|
|
3032
3077
|
var EndpointAdapterFactory = class {
|
|
3033
3078
|
static {
|
|
3034
3079
|
({c: [_EndpointAdapterFactory, _initClass$7]} = _apply_decs_2203_r$7(this, [], [_dec$7]));
|
|
3035
3080
|
}
|
|
3036
|
-
environment = (0,
|
|
3081
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3037
3082
|
create(ctx) {
|
|
3038
3083
|
const service = this.environment.getHttpToken(require_use_guards_decorator.EndpointAdapterToken);
|
|
3039
3084
|
if (!service) throw new Error("EndpointAdapterToken service not found in environment");
|
|
@@ -3325,12 +3370,12 @@ function _apply_decs_2203_r$6(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3325
3370
|
}
|
|
3326
3371
|
var _dec$6, _initClass$6;
|
|
3327
3372
|
let _HttpAdapterFactory;
|
|
3328
|
-
_dec$6 = (0,
|
|
3373
|
+
_dec$6 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.HttpAdapterToken });
|
|
3329
3374
|
var HttpAdapterFactory = class {
|
|
3330
3375
|
static {
|
|
3331
3376
|
({c: [_HttpAdapterFactory, _initClass$6]} = _apply_decs_2203_r$6(this, [], [_dec$6]));
|
|
3332
3377
|
}
|
|
3333
|
-
environment = (0,
|
|
3378
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3334
3379
|
create(ctx) {
|
|
3335
3380
|
const service = this.environment.getHttpToken(require_use_guards_decorator.HttpAdapterToken);
|
|
3336
3381
|
if (!service) throw new Error("HttpAdapterToken service not found in environment");
|
|
@@ -3622,12 +3667,12 @@ function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3622
3667
|
}
|
|
3623
3668
|
var _dec$5, _initClass$5;
|
|
3624
3669
|
let _MultipartAdapterFactory;
|
|
3625
|
-
_dec$5 = (0,
|
|
3670
|
+
_dec$5 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.MultipartAdapterToken });
|
|
3626
3671
|
var MultipartAdapterFactory = class {
|
|
3627
3672
|
static {
|
|
3628
3673
|
({c: [_MultipartAdapterFactory, _initClass$5]} = _apply_decs_2203_r$5(this, [], [_dec$5]));
|
|
3629
3674
|
}
|
|
3630
|
-
environment = (0,
|
|
3675
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3631
3676
|
create(ctx) {
|
|
3632
3677
|
const service = this.environment.getHttpToken(require_use_guards_decorator.MultipartAdapterToken);
|
|
3633
3678
|
if (!service) throw new Error("MultipartAdapterToken service not found in environment");
|
|
@@ -3919,15 +3964,15 @@ function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3919
3964
|
}
|
|
3920
3965
|
var _dec$4, _initClass$4;
|
|
3921
3966
|
let _RequestFactory;
|
|
3922
|
-
_dec$4 = (0,
|
|
3967
|
+
_dec$4 = (0, _navios_di.Factory)({
|
|
3923
3968
|
token: require_use_guards_decorator.Request,
|
|
3924
|
-
scope:
|
|
3969
|
+
scope: _navios_di.InjectableScope.Request
|
|
3925
3970
|
});
|
|
3926
3971
|
var RequestFactory = class {
|
|
3927
3972
|
static {
|
|
3928
3973
|
({c: [_RequestFactory, _initClass$4]} = _apply_decs_2203_r$4(this, [], [_dec$4]));
|
|
3929
3974
|
}
|
|
3930
|
-
environment = (0,
|
|
3975
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3931
3976
|
create(ctx) {
|
|
3932
3977
|
const service = this.environment.getHttpToken(require_use_guards_decorator.Request);
|
|
3933
3978
|
if (!service) throw new Error("RequestToken service not found in environment");
|
|
@@ -4219,15 +4264,15 @@ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4219
4264
|
}
|
|
4220
4265
|
var _dec$3, _initClass$3;
|
|
4221
4266
|
let _ReplyFactory;
|
|
4222
|
-
_dec$3 = (0,
|
|
4267
|
+
_dec$3 = (0, _navios_di.Factory)({
|
|
4223
4268
|
token: require_use_guards_decorator.Reply,
|
|
4224
|
-
scope:
|
|
4269
|
+
scope: _navios_di.InjectableScope.Request
|
|
4225
4270
|
});
|
|
4226
4271
|
var ReplyFactory = class {
|
|
4227
4272
|
static {
|
|
4228
4273
|
({c: [_ReplyFactory, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
|
|
4229
4274
|
}
|
|
4230
|
-
environment = (0,
|
|
4275
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4231
4276
|
create(ctx) {
|
|
4232
4277
|
const service = this.environment.getHttpToken(require_use_guards_decorator.Reply);
|
|
4233
4278
|
if (!service) throw new Error("ReplyToken service not found in environment");
|
|
@@ -4519,12 +4564,12 @@ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4519
4564
|
}
|
|
4520
4565
|
var _dec$2, _initClass$2;
|
|
4521
4566
|
let _StreamAdapterFactory;
|
|
4522
|
-
_dec$2 = (0,
|
|
4567
|
+
_dec$2 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.StreamAdapterToken });
|
|
4523
4568
|
var StreamAdapterFactory = class {
|
|
4524
4569
|
static {
|
|
4525
4570
|
({c: [_StreamAdapterFactory, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
|
|
4526
4571
|
}
|
|
4527
|
-
environment = (0,
|
|
4572
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4528
4573
|
create(ctx) {
|
|
4529
4574
|
const service = this.environment.getHttpToken(require_use_guards_decorator.StreamAdapterToken);
|
|
4530
4575
|
if (!service) throw new Error("StreamAdapterToken service not found in environment");
|
|
@@ -4816,12 +4861,12 @@ function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4816
4861
|
}
|
|
4817
4862
|
var _dec$1, _initClass$1;
|
|
4818
4863
|
let _XmlStreamAdapterFactory;
|
|
4819
|
-
_dec$1 = (0,
|
|
4864
|
+
_dec$1 = (0, _navios_di.Factory)({ token: require_use_guards_decorator.XmlStreamAdapterToken });
|
|
4820
4865
|
var XmlStreamAdapterFactory = class {
|
|
4821
4866
|
static {
|
|
4822
4867
|
({c: [_XmlStreamAdapterFactory, _initClass$1]} = _apply_decs_2203_r$1(this, [], [_dec$1]));
|
|
4823
4868
|
}
|
|
4824
|
-
environment = (0,
|
|
4869
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4825
4870
|
create(ctx) {
|
|
4826
4871
|
const service = this.environment.getHttpToken(require_use_guards_decorator.XmlStreamAdapterToken);
|
|
4827
4872
|
if (!service) throw new Error("XmlStreamAdapterToken service not found in environment");
|
|
@@ -5113,18 +5158,19 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
5113
5158
|
}
|
|
5114
5159
|
var _dec, _initClass;
|
|
5115
5160
|
let _NaviosApplication;
|
|
5116
|
-
_dec = (0,
|
|
5161
|
+
_dec = (0, _navios_di.Injectable)();
|
|
5117
5162
|
var NaviosApplication = class {
|
|
5118
5163
|
static {
|
|
5119
5164
|
({c: [_NaviosApplication, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
|
|
5120
5165
|
}
|
|
5121
|
-
environment = (0,
|
|
5122
|
-
moduleLoader = (0,
|
|
5166
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
5167
|
+
moduleLoader = (0, _navios_di.inject)(_ModuleLoaderService);
|
|
5123
5168
|
httpApplication = null;
|
|
5124
|
-
logger = (0,
|
|
5125
|
-
container = (0,
|
|
5169
|
+
logger = (0, _navios_di.inject)(Logger, { context: _NaviosApplication.name });
|
|
5170
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
5126
5171
|
appModule = null;
|
|
5127
5172
|
options = { adapter: [] };
|
|
5173
|
+
plugins = [];
|
|
5128
5174
|
/**
|
|
5129
5175
|
* Indicates whether the application has been initialized.
|
|
5130
5176
|
* Set to `true` after `init()` completes successfully.
|
|
@@ -5132,7 +5178,7 @@ var NaviosApplication = class {
|
|
|
5132
5178
|
/**
|
|
5133
5179
|
* Sets up the application with the provided module and options.
|
|
5134
5180
|
* This is called automatically by NaviosFactory.create().
|
|
5135
|
-
*
|
|
5181
|
+
*
|
|
5136
5182
|
* @param appModule - The root application module
|
|
5137
5183
|
* @param options - Application configuration options
|
|
5138
5184
|
* @internal
|
|
@@ -5143,24 +5189,46 @@ var NaviosApplication = class {
|
|
|
5143
5189
|
}
|
|
5144
5190
|
/**
|
|
5145
5191
|
* Gets the dependency injection container used by this application.
|
|
5146
|
-
*
|
|
5192
|
+
*
|
|
5147
5193
|
* @returns The Container instance
|
|
5148
5194
|
*/ getContainer() {
|
|
5149
5195
|
return this.container;
|
|
5150
5196
|
}
|
|
5151
5197
|
/**
|
|
5198
|
+
* Registers a plugin to be initialized after modules are loaded.
|
|
5199
|
+
*
|
|
5200
|
+
* Plugins are initialized in the order they are registered,
|
|
5201
|
+
* after all modules are loaded but before the server starts listening.
|
|
5202
|
+
*
|
|
5203
|
+
* @param definition - Plugin definition with options
|
|
5204
|
+
* @returns this for method chaining
|
|
5205
|
+
*
|
|
5206
|
+
* @example
|
|
5207
|
+
* ```typescript
|
|
5208
|
+
* import { defineOpenApiPlugin } from '@navios/openapi-fastify'
|
|
5209
|
+
*
|
|
5210
|
+
* app.usePlugin(defineOpenApiPlugin({
|
|
5211
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
5212
|
+
* }))
|
|
5213
|
+
* ```
|
|
5214
|
+
*/ usePlugin(definition) {
|
|
5215
|
+
this.plugins.push(definition);
|
|
5216
|
+
return this;
|
|
5217
|
+
}
|
|
5218
|
+
/**
|
|
5152
5219
|
* Initializes the application.
|
|
5153
|
-
*
|
|
5220
|
+
*
|
|
5154
5221
|
* This method:
|
|
5155
5222
|
* - Loads all modules and their dependencies
|
|
5156
5223
|
* - Sets up the HTTP server if an adapter is configured
|
|
5157
5224
|
* - Calls onModuleInit hooks on all modules
|
|
5225
|
+
* - Initializes registered plugins
|
|
5158
5226
|
* - Marks the application as initialized
|
|
5159
|
-
*
|
|
5227
|
+
*
|
|
5160
5228
|
* Must be called before `listen()`.
|
|
5161
|
-
*
|
|
5229
|
+
*
|
|
5162
5230
|
* @throws Error if app module is not set
|
|
5163
|
-
*
|
|
5231
|
+
*
|
|
5164
5232
|
* @example
|
|
5165
5233
|
* ```typescript
|
|
5166
5234
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5173,6 +5241,7 @@ var NaviosApplication = class {
|
|
|
5173
5241
|
if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
|
|
5174
5242
|
await this.moduleLoader.loadModules(this.appModule);
|
|
5175
5243
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
|
|
5244
|
+
await this.initPlugins();
|
|
5176
5245
|
await this.initModules();
|
|
5177
5246
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
|
|
5178
5247
|
this.isInitialized = true;
|
|
@@ -5182,12 +5251,30 @@ var NaviosApplication = class {
|
|
|
5182
5251
|
const modules = this.moduleLoader.getAllModules();
|
|
5183
5252
|
await this.httpApplication?.onModulesInit(modules);
|
|
5184
5253
|
}
|
|
5254
|
+
async initPlugins() {
|
|
5255
|
+
if (this.plugins.length === 0) return;
|
|
5256
|
+
let server = null;
|
|
5257
|
+
try {
|
|
5258
|
+
server = this.httpApplication?.getServer() ?? null;
|
|
5259
|
+
} catch {}
|
|
5260
|
+
const context = {
|
|
5261
|
+
modules: this.moduleLoader.getAllModules(),
|
|
5262
|
+
server,
|
|
5263
|
+
container: this.container,
|
|
5264
|
+
globalPrefix: this.httpApplication?.getGlobalPrefix() ?? "",
|
|
5265
|
+
moduleLoader: this.moduleLoader
|
|
5266
|
+
};
|
|
5267
|
+
for (const { plugin, options } of this.plugins) {
|
|
5268
|
+
this.logger.debug(`Initializing plugin: ${plugin.name}`);
|
|
5269
|
+
await plugin.register(context, options);
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5185
5272
|
/**
|
|
5186
5273
|
* Enables CORS (Cross-Origin Resource Sharing) for the application.
|
|
5187
|
-
*
|
|
5274
|
+
*
|
|
5188
5275
|
* @param options - CORS configuration options (adapter-specific)
|
|
5189
5276
|
* @throws Error if HTTP application is not set
|
|
5190
|
-
*
|
|
5277
|
+
*
|
|
5191
5278
|
* @example
|
|
5192
5279
|
* ```typescript
|
|
5193
5280
|
* app.enableCors({
|
|
@@ -5202,10 +5289,10 @@ var NaviosApplication = class {
|
|
|
5202
5289
|
}
|
|
5203
5290
|
/**
|
|
5204
5291
|
* Enables multipart/form-data support for file uploads.
|
|
5205
|
-
*
|
|
5292
|
+
*
|
|
5206
5293
|
* @param options - Multipart configuration options (adapter-specific)
|
|
5207
5294
|
* @throws Error if HTTP application is not set
|
|
5208
|
-
*
|
|
5295
|
+
*
|
|
5209
5296
|
* @example
|
|
5210
5297
|
* ```typescript
|
|
5211
5298
|
* app.enableMultipart({
|
|
@@ -5220,10 +5307,10 @@ var NaviosApplication = class {
|
|
|
5220
5307
|
}
|
|
5221
5308
|
/**
|
|
5222
5309
|
* Sets a global prefix for all routes.
|
|
5223
|
-
*
|
|
5310
|
+
*
|
|
5224
5311
|
* @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
|
|
5225
5312
|
* @throws Error if HTTP application is not set
|
|
5226
|
-
*
|
|
5313
|
+
*
|
|
5227
5314
|
* @example
|
|
5228
5315
|
* ```typescript
|
|
5229
5316
|
* app.setGlobalPrefix('/api/v1')
|
|
@@ -5235,14 +5322,14 @@ var NaviosApplication = class {
|
|
|
5235
5322
|
}
|
|
5236
5323
|
/**
|
|
5237
5324
|
* Gets the underlying HTTP server instance.
|
|
5238
|
-
*
|
|
5325
|
+
*
|
|
5239
5326
|
* The type of the returned server depends on the adapter used:
|
|
5240
5327
|
* - Fastify adapter: Returns FastifyInstance
|
|
5241
5328
|
* - Bun adapter: Returns Bun.Server
|
|
5242
|
-
*
|
|
5329
|
+
*
|
|
5243
5330
|
* @returns The HTTP server instance
|
|
5244
5331
|
* @throws Error if HTTP application is not set
|
|
5245
|
-
*
|
|
5332
|
+
*
|
|
5246
5333
|
* @example
|
|
5247
5334
|
* ```typescript
|
|
5248
5335
|
* const server = app.getServer()
|
|
@@ -5254,10 +5341,10 @@ var NaviosApplication = class {
|
|
|
5254
5341
|
}
|
|
5255
5342
|
/**
|
|
5256
5343
|
* Starts the HTTP server and begins listening for requests.
|
|
5257
|
-
*
|
|
5344
|
+
*
|
|
5258
5345
|
* @param options - Listen options (port, host, etc.)
|
|
5259
5346
|
* @throws Error if HTTP application is not set
|
|
5260
|
-
*
|
|
5347
|
+
*
|
|
5261
5348
|
* @example
|
|
5262
5349
|
* ```typescript
|
|
5263
5350
|
* await app.listen({ port: 3000, host: '0.0.0.0' })
|
|
@@ -5268,7 +5355,7 @@ var NaviosApplication = class {
|
|
|
5268
5355
|
}
|
|
5269
5356
|
/**
|
|
5270
5357
|
* Disposes of application resources.
|
|
5271
|
-
*
|
|
5358
|
+
*
|
|
5272
5359
|
* Cleans up the HTTP server and module loader.
|
|
5273
5360
|
* This method is called automatically by `close()`.
|
|
5274
5361
|
*/ async dispose() {
|
|
@@ -5277,9 +5364,9 @@ var NaviosApplication = class {
|
|
|
5277
5364
|
}
|
|
5278
5365
|
/**
|
|
5279
5366
|
* Closes the application and cleans up all resources.
|
|
5280
|
-
*
|
|
5367
|
+
*
|
|
5281
5368
|
* This is an alias for `dispose()`.
|
|
5282
|
-
*
|
|
5369
|
+
*
|
|
5283
5370
|
* @example
|
|
5284
5371
|
* ```typescript
|
|
5285
5372
|
* // Graceful shutdown
|
|
@@ -5300,31 +5387,31 @@ var NaviosApplication = class {
|
|
|
5300
5387
|
//#region src/navios.factory.mts
|
|
5301
5388
|
/**
|
|
5302
5389
|
* Factory class for creating and configuring Navios applications.
|
|
5303
|
-
*
|
|
5390
|
+
*
|
|
5304
5391
|
* This is the main entry point for bootstrapping a Navios application.
|
|
5305
5392
|
* It handles dependency injection container setup, adapter registration,
|
|
5306
5393
|
* and logger configuration.
|
|
5307
|
-
*
|
|
5394
|
+
*
|
|
5308
5395
|
* @example
|
|
5309
5396
|
* ```typescript
|
|
5310
5397
|
* import { NaviosFactory } from '@navios/core'
|
|
5311
5398
|
* import { defineFastifyEnvironment } from '@navios/adapter-fastify'
|
|
5312
|
-
*
|
|
5399
|
+
*
|
|
5313
5400
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5314
5401
|
* adapter: defineFastifyEnvironment(),
|
|
5315
5402
|
* logger: ['log', 'error', 'warn'],
|
|
5316
5403
|
* })
|
|
5317
|
-
*
|
|
5404
|
+
*
|
|
5318
5405
|
* await app.init()
|
|
5319
5406
|
* await app.listen({ port: 3000 })
|
|
5320
5407
|
* ```
|
|
5321
5408
|
*/ var NaviosFactory = class {
|
|
5322
5409
|
/**
|
|
5323
5410
|
* Creates a new Navios application instance.
|
|
5324
|
-
*
|
|
5411
|
+
*
|
|
5325
5412
|
* This method sets up the dependency injection container, registers the HTTP adapter,
|
|
5326
5413
|
* configures logging, and initializes the application with the provided module.
|
|
5327
|
-
*
|
|
5414
|
+
*
|
|
5328
5415
|
* @param appModule - The root application module class decorated with @Module()
|
|
5329
5416
|
* @param options - Configuration options for the application
|
|
5330
5417
|
* @param options.adapter - HTTP adapter environment (required for HTTP server functionality)
|
|
@@ -5334,20 +5421,20 @@ var NaviosApplication = class {
|
|
|
5334
5421
|
* - `false` to disable logging
|
|
5335
5422
|
* @param options.container - Optional custom dependency injection container (useful for testing)
|
|
5336
5423
|
* @returns A configured NaviosApplication instance ready to be initialized
|
|
5337
|
-
*
|
|
5424
|
+
*
|
|
5338
5425
|
* @example
|
|
5339
5426
|
* ```typescript
|
|
5340
5427
|
* // Basic setup with Fastify adapter
|
|
5341
5428
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5342
5429
|
* adapter: defineFastifyEnvironment(),
|
|
5343
5430
|
* })
|
|
5344
|
-
*
|
|
5431
|
+
*
|
|
5345
5432
|
* // With custom logger configuration
|
|
5346
5433
|
* const app = await NaviosFactory.create(AppModule, {
|
|
5347
5434
|
* adapter: defineFastifyEnvironment(),
|
|
5348
5435
|
* logger: ['error', 'warn', 'log'],
|
|
5349
5436
|
* })
|
|
5350
|
-
*
|
|
5437
|
+
*
|
|
5351
5438
|
* // With custom container for testing
|
|
5352
5439
|
* const container = new Container()
|
|
5353
5440
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5356,7 +5443,7 @@ var NaviosApplication = class {
|
|
|
5356
5443
|
* })
|
|
5357
5444
|
* ```
|
|
5358
5445
|
*/ static async create(appModule, options = { adapter: [] }) {
|
|
5359
|
-
const container = options.container ?? new
|
|
5446
|
+
const container = options.container ?? new _navios_di.Container();
|
|
5360
5447
|
await this.registerLoggerConfiguration(container, options);
|
|
5361
5448
|
const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
|
|
5362
5449
|
for (const adapter of adapters) await this.registerEnvironment(container, adapter);
|
|
@@ -5371,8 +5458,11 @@ var NaviosApplication = class {
|
|
|
5371
5458
|
}
|
|
5372
5459
|
static async registerLoggerConfiguration(container, options) {
|
|
5373
5460
|
const { logger } = options;
|
|
5374
|
-
if (Array.isArray(logger) || isNil(logger))
|
|
5375
|
-
|
|
5461
|
+
if (Array.isArray(logger) || isNil(logger)) {
|
|
5462
|
+
(await container.get(LoggerOutput))?.setup({ logLevels: logger });
|
|
5463
|
+
return;
|
|
5464
|
+
}
|
|
5465
|
+
if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
|
|
5376
5466
|
}
|
|
5377
5467
|
};
|
|
5378
5468
|
|
|
@@ -5707,4 +5797,4 @@ Object.defineProperty(exports, 'yellow', {
|
|
|
5707
5797
|
return yellow;
|
|
5708
5798
|
}
|
|
5709
5799
|
});
|
|
5710
|
-
//# sourceMappingURL=src-
|
|
5800
|
+
//# sourceMappingURL=src-QnxR5b7c.cjs.map
|