@navios/commander 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 +6 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +99 -68
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +45 -14
- package/lib/index.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/src/interfaces/cli-module.interface.d.mts +0 -5
- package/dist/src/interfaces/cli-module.interface.d.mts.map +0 -1
- package/dist/src/interfaces/module.interface.d.mts +0 -2
- package/dist/src/interfaces/module.interface.d.mts.map +0 -1
- package/dist/tsup.config.d.mts +0 -3
- package/dist/tsup.config.d.mts.map +0 -1
package/lib/index.cjs
CHANGED
|
@@ -32,20 +32,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
32
32
|
}
|
|
33
33
|
return to;
|
|
34
34
|
};
|
|
35
|
-
var __reExport = (target, mod, secondTarget,
|
|
36
|
-
if (symbols) {
|
|
37
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
38
|
-
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
39
|
-
}
|
|
40
|
-
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
41
|
-
};
|
|
35
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
42
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
43
37
|
value: mod,
|
|
44
38
|
enumerable: true
|
|
45
39
|
}) : target, mod));
|
|
46
40
|
|
|
47
41
|
//#endregion
|
|
48
|
-
let
|
|
42
|
+
let _navios_di = require("@navios/di");
|
|
49
43
|
let node_process = require("node:process");
|
|
50
44
|
let zod_v4 = require("zod/v4");
|
|
51
45
|
zod_v4 = __toESM(zod_v4);
|
|
@@ -165,26 +159,26 @@ function hasModuleMetadata(target) {
|
|
|
165
159
|
*/ function Controller({ guards } = {}) {
|
|
166
160
|
return function(target, context) {
|
|
167
161
|
if (context.kind !== "class") throw new Error("[Navios] @Controller decorator can only be used on classes.");
|
|
168
|
-
const token =
|
|
162
|
+
const token = _navios_di.InjectionToken.create(target);
|
|
169
163
|
if (context.metadata) {
|
|
170
164
|
const controllerMetadata = getControllerMetadata(target, context);
|
|
171
165
|
if (guards) for (const guard of Array.from(guards).reverse()) controllerMetadata.guards.add(guard);
|
|
172
166
|
}
|
|
173
|
-
return (0,
|
|
167
|
+
return (0, _navios_di.Injectable)({
|
|
174
168
|
token,
|
|
175
|
-
scope:
|
|
169
|
+
scope: _navios_di.InjectableScope.Request
|
|
176
170
|
})(target, context);
|
|
177
171
|
};
|
|
178
172
|
}
|
|
179
|
-
const EndpointAdapterToken =
|
|
173
|
+
const EndpointAdapterToken = _navios_di.InjectionToken.create("EndpointAdapterToken");
|
|
180
174
|
const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
|
|
181
|
-
const ExecutionContext =
|
|
182
|
-
const HttpAdapterToken =
|
|
183
|
-
const MultipartAdapterToken =
|
|
184
|
-
const Reply =
|
|
185
|
-
const Request =
|
|
186
|
-
const StreamAdapterToken =
|
|
187
|
-
const XmlStreamAdapterToken =
|
|
175
|
+
const ExecutionContext = _navios_di.InjectionToken.create(ExecutionContextInjectionToken);
|
|
176
|
+
const HttpAdapterToken = _navios_di.InjectionToken.create("HttpAdapterToken");
|
|
177
|
+
const MultipartAdapterToken = _navios_di.InjectionToken.create("MultipartAdapterToken");
|
|
178
|
+
const Reply = _navios_di.InjectionToken.create("ReplyToken");
|
|
179
|
+
const Request = _navios_di.InjectionToken.create("RequestToken");
|
|
180
|
+
const StreamAdapterToken = _navios_di.InjectionToken.create("StreamAdapterToken");
|
|
181
|
+
const XmlStreamAdapterToken = _navios_di.InjectionToken.create("XmlStreamAdapterToken");
|
|
188
182
|
/**
|
|
189
183
|
* Decorator that marks a method as an HTTP endpoint.
|
|
190
184
|
*
|
|
@@ -308,14 +302,14 @@ const XmlStreamAdapterToken = __navios_di.InjectionToken.create("XmlStreamAdapte
|
|
|
308
302
|
}) {
|
|
309
303
|
return (target, context) => {
|
|
310
304
|
if (context.kind !== "class") throw new Error("[Navios] @Module decorator can only be used on classes.");
|
|
311
|
-
const token =
|
|
305
|
+
const token = _navios_di.InjectionToken.create(target);
|
|
312
306
|
const moduleMetadata = getModuleMetadata(target, context);
|
|
313
307
|
for (const controller of controllers) moduleMetadata.controllers.add(controller);
|
|
314
308
|
for (const importedModule of imports) moduleMetadata.imports.add(importedModule);
|
|
315
309
|
for (const guard of Array.from(guards).reverse()) moduleMetadata.guards.add(guard);
|
|
316
|
-
return (0,
|
|
310
|
+
return (0, _navios_di.Injectable)({
|
|
317
311
|
token,
|
|
318
|
-
scope:
|
|
312
|
+
scope: _navios_di.InjectableScope.Singleton
|
|
319
313
|
})(target, context);
|
|
320
314
|
};
|
|
321
315
|
}
|
|
@@ -474,7 +468,7 @@ const XmlStreamAdapterToken = __navios_di.InjectionToken.create("XmlStreamAdapte
|
|
|
474
468
|
};
|
|
475
469
|
|
|
476
470
|
//#endregion
|
|
477
|
-
//#region ../core/lib/src-
|
|
471
|
+
//#region ../core/lib/src-DpPBxmjz.mjs
|
|
478
472
|
function envInt(key, defaultValue) {
|
|
479
473
|
const envKey = node_process.env[key] || process.env[key];
|
|
480
474
|
return envKey ? parseInt(envKey, 10) : defaultValue;
|
|
@@ -598,7 +592,7 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
598
592
|
*
|
|
599
593
|
* This token is used to provide a custom logger implementation.
|
|
600
594
|
* By default, it's bound to ConsoleLogger.
|
|
601
|
-
*/ const LoggerOutput =
|
|
595
|
+
*/ const LoggerOutput = _navios_di.InjectionToken.create("LoggerOutput");
|
|
602
596
|
/**
|
|
603
597
|
* Schema for logger options.
|
|
604
598
|
*/ const loggerOptionsSchema = zod_v4.default.object({ context: zod_v4.default.string().optional() }).optional();
|
|
@@ -612,7 +606,7 @@ const isSymbol = (val) => typeof val === "symbol";
|
|
|
612
606
|
* const logger = inject(Logger, { context: 'MyService' })
|
|
613
607
|
* logger.log('Hello world') // Logs with context: [MyService]
|
|
614
608
|
* ```
|
|
615
|
-
*/ const Logger =
|
|
609
|
+
*/ const Logger = _navios_di.InjectionToken.create("Logger", loggerOptionsSchema);
|
|
616
610
|
function applyDecs2203RFactory$13() {
|
|
617
611
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
618
612
|
return function addInitializer(initializer) {
|
|
@@ -909,7 +903,7 @@ const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
|
909
903
|
month: "2-digit"
|
|
910
904
|
});
|
|
911
905
|
let _ConsoleLogger;
|
|
912
|
-
_dec$13 = (0,
|
|
906
|
+
_dec$13 = (0, _navios_di.Injectable)({ token: LoggerOutput });
|
|
913
907
|
(class {
|
|
914
908
|
static {
|
|
915
909
|
({c: [_ConsoleLogger, _initClass$13]} = _apply_decs_2203_r$13(this, [], [_dec$13]));
|
|
@@ -1443,7 +1437,7 @@ function _apply_decs_2203_r$12(targetClass, memberDecs, classDecs, parentClass)
|
|
|
1443
1437
|
}
|
|
1444
1438
|
var _dec$12, _initClass$12;
|
|
1445
1439
|
let _LoggerInstance;
|
|
1446
|
-
_dec$12 = (0,
|
|
1440
|
+
_dec$12 = (0, _navios_di.Injectable)({ token: Logger });
|
|
1447
1441
|
(class {
|
|
1448
1442
|
static {
|
|
1449
1443
|
({c: [_LoggerInstance, _initClass$12]} = _apply_decs_2203_r$12(this, [], [_dec$12]));
|
|
@@ -1451,7 +1445,7 @@ _dec$12 = (0, __navios_di.Injectable)({ token: Logger });
|
|
|
1451
1445
|
constructor(config = {}) {
|
|
1452
1446
|
this.context = config.context;
|
|
1453
1447
|
}
|
|
1454
|
-
localInstance = (0,
|
|
1448
|
+
localInstance = (0, _navios_di.inject)(LoggerOutput);
|
|
1455
1449
|
context;
|
|
1456
1450
|
error(message, ...optionalParams) {
|
|
1457
1451
|
optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(this.context) : optionalParams;
|
|
@@ -1764,9 +1758,9 @@ var _dec$11, _initClass$11;
|
|
|
1764
1758
|
*/ const ConfigServiceOptionsSchema = zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown());
|
|
1765
1759
|
/**
|
|
1766
1760
|
* Injection token for ConfigService.
|
|
1767
|
-
*/ const ConfigServiceToken =
|
|
1761
|
+
*/ const ConfigServiceToken = _navios_di.InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
|
|
1768
1762
|
let _ConfigService;
|
|
1769
|
-
_dec$11 = (0,
|
|
1763
|
+
_dec$11 = (0, _navios_di.Injectable)({ token: ConfigServiceToken });
|
|
1770
1764
|
(class {
|
|
1771
1765
|
config;
|
|
1772
1766
|
static {
|
|
@@ -1779,7 +1773,7 @@ _dec$11 = (0, __navios_di.Injectable)({ token: ConfigServiceToken });
|
|
|
1779
1773
|
*/ constructor(config = {}) {
|
|
1780
1774
|
this.config = config;
|
|
1781
1775
|
}
|
|
1782
|
-
logger = (0,
|
|
1776
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ConfigService.name });
|
|
1783
1777
|
/**
|
|
1784
1778
|
* Gets the entire configuration object.
|
|
1785
1779
|
*
|
|
@@ -1880,7 +1874,7 @@ _dec$11 = (0, __navios_di.Injectable)({ token: ConfigServiceToken });
|
|
|
1880
1874
|
* container.bind(ConfigServiceToken).toFactory(configProvider)
|
|
1881
1875
|
* ```
|
|
1882
1876
|
*/ function provideConfig(options) {
|
|
1883
|
-
return
|
|
1877
|
+
return _navios_di.InjectionToken.factory(ConfigServiceToken, async () => options.load());
|
|
1884
1878
|
}
|
|
1885
1879
|
/**
|
|
1886
1880
|
* Pre-configured ConfigService provider that uses environment variables.
|
|
@@ -1892,7 +1886,7 @@ _dec$11 = (0, __navios_di.Injectable)({ token: ConfigServiceToken });
|
|
|
1892
1886
|
* // Use environment variables as configuration
|
|
1893
1887
|
* container.bind(ConfigServiceToken).toValue(EnvConfigProvider)
|
|
1894
1888
|
* ```
|
|
1895
|
-
*/ const EnvConfigProvider =
|
|
1889
|
+
*/ const EnvConfigProvider = _navios_di.InjectionToken.bound(ConfigServiceToken, { ...node_process.env });
|
|
1896
1890
|
/**
|
|
1897
1891
|
* Base exception class for all HTTP exceptions in Navios.
|
|
1898
1892
|
*
|
|
@@ -2366,12 +2360,12 @@ function _apply_decs_2203_r$10(targetClass, memberDecs, classDecs, parentClass)
|
|
|
2366
2360
|
}
|
|
2367
2361
|
var _dec$10, _initClass$10;
|
|
2368
2362
|
let _GuardRunnerService;
|
|
2369
|
-
_dec$10 = (0,
|
|
2363
|
+
_dec$10 = (0, _navios_di.Injectable)();
|
|
2370
2364
|
(class {
|
|
2371
2365
|
static {
|
|
2372
2366
|
({c: [_GuardRunnerService, _initClass$10]} = _apply_decs_2203_r$10(this, [], [_dec$10]));
|
|
2373
2367
|
}
|
|
2374
|
-
logger = (0,
|
|
2368
|
+
logger = (0, _navios_di.inject)(Logger, { context: _GuardRunnerService.name });
|
|
2375
2369
|
async runGuards(allGuards, executionContext, context) {
|
|
2376
2370
|
let canActivate = true;
|
|
2377
2371
|
for (const guard of Array.from(allGuards).reverse()) {
|
|
@@ -2690,13 +2684,13 @@ function _apply_decs_2203_r$9(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
2690
2684
|
}
|
|
2691
2685
|
var _dec$9, _initClass$9;
|
|
2692
2686
|
let _ModuleLoaderService;
|
|
2693
|
-
_dec$9 = (0,
|
|
2687
|
+
_dec$9 = (0, _navios_di.Injectable)();
|
|
2694
2688
|
(class {
|
|
2695
2689
|
static {
|
|
2696
2690
|
({c: [_ModuleLoaderService, _initClass$9]} = _apply_decs_2203_r$9(this, [], [_dec$9]));
|
|
2697
2691
|
}
|
|
2698
|
-
logger = (0,
|
|
2699
|
-
container = (0,
|
|
2692
|
+
logger = (0, _navios_di.inject)(Logger, { context: _ModuleLoaderService.name });
|
|
2693
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
2700
2694
|
modulesMetadata = /* @__PURE__ */ new Map();
|
|
2701
2695
|
loadedModules = /* @__PURE__ */ new Map();
|
|
2702
2696
|
initialized = false;
|
|
@@ -3098,7 +3092,7 @@ function _apply_decs_2203_r$8(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3098
3092
|
}
|
|
3099
3093
|
var _dec$8, _initClass$8;
|
|
3100
3094
|
let _NaviosEnvironment;
|
|
3101
|
-
_dec$8 = (0,
|
|
3095
|
+
_dec$8 = (0, _navios_di.Injectable)();
|
|
3102
3096
|
(class {
|
|
3103
3097
|
static {
|
|
3104
3098
|
({c: [_NaviosEnvironment, _initClass$8]} = _apply_decs_2203_r$8(this, [], [_dec$8]));
|
|
@@ -3396,12 +3390,12 @@ function _apply_decs_2203_r$7(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3396
3390
|
}
|
|
3397
3391
|
var _dec$7, _initClass$7;
|
|
3398
3392
|
let _EndpointAdapterFactory;
|
|
3399
|
-
_dec$7 = (0,
|
|
3393
|
+
_dec$7 = (0, _navios_di.Factory)({ token: EndpointAdapterToken });
|
|
3400
3394
|
(class {
|
|
3401
3395
|
static {
|
|
3402
3396
|
({c: [_EndpointAdapterFactory, _initClass$7]} = _apply_decs_2203_r$7(this, [], [_dec$7]));
|
|
3403
3397
|
}
|
|
3404
|
-
environment = (0,
|
|
3398
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3405
3399
|
create(ctx) {
|
|
3406
3400
|
const service = this.environment.getHttpToken(EndpointAdapterToken);
|
|
3407
3401
|
if (!service) throw new Error("EndpointAdapterToken service not found in environment");
|
|
@@ -3690,12 +3684,12 @@ function _apply_decs_2203_r$6(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3690
3684
|
}
|
|
3691
3685
|
var _dec$6, _initClass$6;
|
|
3692
3686
|
let _HttpAdapterFactory;
|
|
3693
|
-
_dec$6 = (0,
|
|
3687
|
+
_dec$6 = (0, _navios_di.Factory)({ token: HttpAdapterToken });
|
|
3694
3688
|
(class {
|
|
3695
3689
|
static {
|
|
3696
3690
|
({c: [_HttpAdapterFactory, _initClass$6]} = _apply_decs_2203_r$6(this, [], [_dec$6]));
|
|
3697
3691
|
}
|
|
3698
|
-
environment = (0,
|
|
3692
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3699
3693
|
create(ctx) {
|
|
3700
3694
|
const service = this.environment.getHttpToken(HttpAdapterToken);
|
|
3701
3695
|
if (!service) throw new Error("HttpAdapterToken service not found in environment");
|
|
@@ -3984,12 +3978,12 @@ function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
3984
3978
|
}
|
|
3985
3979
|
var _dec$5, _initClass$5;
|
|
3986
3980
|
let _MultipartAdapterFactory;
|
|
3987
|
-
_dec$5 = (0,
|
|
3981
|
+
_dec$5 = (0, _navios_di.Factory)({ token: MultipartAdapterToken });
|
|
3988
3982
|
(class {
|
|
3989
3983
|
static {
|
|
3990
3984
|
({c: [_MultipartAdapterFactory, _initClass$5]} = _apply_decs_2203_r$5(this, [], [_dec$5]));
|
|
3991
3985
|
}
|
|
3992
|
-
environment = (0,
|
|
3986
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
3993
3987
|
create(ctx) {
|
|
3994
3988
|
const service = this.environment.getHttpToken(MultipartAdapterToken);
|
|
3995
3989
|
if (!service) throw new Error("MultipartAdapterToken service not found in environment");
|
|
@@ -4278,15 +4272,15 @@ function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4278
4272
|
}
|
|
4279
4273
|
var _dec$4, _initClass$4;
|
|
4280
4274
|
let _RequestFactory;
|
|
4281
|
-
_dec$4 = (0,
|
|
4275
|
+
_dec$4 = (0, _navios_di.Factory)({
|
|
4282
4276
|
token: Request,
|
|
4283
|
-
scope:
|
|
4277
|
+
scope: _navios_di.InjectableScope.Request
|
|
4284
4278
|
});
|
|
4285
4279
|
(class {
|
|
4286
4280
|
static {
|
|
4287
4281
|
({c: [_RequestFactory, _initClass$4]} = _apply_decs_2203_r$4(this, [], [_dec$4]));
|
|
4288
4282
|
}
|
|
4289
|
-
environment = (0,
|
|
4283
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4290
4284
|
create(ctx) {
|
|
4291
4285
|
const service = this.environment.getHttpToken(Request);
|
|
4292
4286
|
if (!service) throw new Error("RequestToken service not found in environment");
|
|
@@ -4575,15 +4569,15 @@ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
4575
4569
|
}
|
|
4576
4570
|
var _dec$3, _initClass$3;
|
|
4577
4571
|
let _ReplyFactory;
|
|
4578
|
-
_dec$3 = (0,
|
|
4572
|
+
_dec$3 = (0, _navios_di.Factory)({
|
|
4579
4573
|
token: Reply,
|
|
4580
|
-
scope:
|
|
4574
|
+
scope: _navios_di.InjectableScope.Request
|
|
4581
4575
|
});
|
|
4582
4576
|
(class {
|
|
4583
4577
|
static {
|
|
4584
4578
|
({c: [_ReplyFactory, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
|
|
4585
4579
|
}
|
|
4586
|
-
environment = (0,
|
|
4580
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4587
4581
|
create(ctx) {
|
|
4588
4582
|
const service = this.environment.getHttpToken(Reply);
|
|
4589
4583
|
if (!service) throw new Error("ReplyToken service not found in environment");
|
|
@@ -4872,12 +4866,12 @@ function _apply_decs_2203_r$2$1(targetClass, memberDecs, classDecs, parentClass)
|
|
|
4872
4866
|
}
|
|
4873
4867
|
var _dec$2$1, _initClass$2$1;
|
|
4874
4868
|
let _StreamAdapterFactory;
|
|
4875
|
-
_dec$2$1 = (0,
|
|
4869
|
+
_dec$2$1 = (0, _navios_di.Factory)({ token: StreamAdapterToken });
|
|
4876
4870
|
(class {
|
|
4877
4871
|
static {
|
|
4878
4872
|
({c: [_StreamAdapterFactory, _initClass$2$1]} = _apply_decs_2203_r$2$1(this, [], [_dec$2$1]));
|
|
4879
4873
|
}
|
|
4880
|
-
environment = (0,
|
|
4874
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
4881
4875
|
create(ctx) {
|
|
4882
4876
|
const service = this.environment.getHttpToken(StreamAdapterToken);
|
|
4883
4877
|
if (!service) throw new Error("StreamAdapterToken service not found in environment");
|
|
@@ -5166,12 +5160,12 @@ function _apply_decs_2203_r$1$1(targetClass, memberDecs, classDecs, parentClass)
|
|
|
5166
5160
|
}
|
|
5167
5161
|
var _dec$1$1, _initClass$1$1;
|
|
5168
5162
|
let _XmlStreamAdapterFactory;
|
|
5169
|
-
_dec$1$1 = (0,
|
|
5163
|
+
_dec$1$1 = (0, _navios_di.Factory)({ token: XmlStreamAdapterToken });
|
|
5170
5164
|
(class {
|
|
5171
5165
|
static {
|
|
5172
5166
|
({c: [_XmlStreamAdapterFactory, _initClass$1$1]} = _apply_decs_2203_r$1$1(this, [], [_dec$1$1]));
|
|
5173
5167
|
}
|
|
5174
|
-
environment = (0,
|
|
5168
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
5175
5169
|
create(ctx) {
|
|
5176
5170
|
const service = this.environment.getHttpToken(XmlStreamAdapterToken);
|
|
5177
5171
|
if (!service) throw new Error("XmlStreamAdapterToken service not found in environment");
|
|
@@ -5460,18 +5454,19 @@ function _apply_decs_2203_r$14(targetClass, memberDecs, classDecs, parentClass)
|
|
|
5460
5454
|
}
|
|
5461
5455
|
var _dec$14, _initClass$14;
|
|
5462
5456
|
let _NaviosApplication;
|
|
5463
|
-
_dec$14 = (0,
|
|
5457
|
+
_dec$14 = (0, _navios_di.Injectable)();
|
|
5464
5458
|
(class {
|
|
5465
5459
|
static {
|
|
5466
5460
|
({c: [_NaviosApplication, _initClass$14]} = _apply_decs_2203_r$14(this, [], [_dec$14]));
|
|
5467
5461
|
}
|
|
5468
|
-
environment = (0,
|
|
5469
|
-
moduleLoader = (0,
|
|
5462
|
+
environment = (0, _navios_di.inject)(_NaviosEnvironment);
|
|
5463
|
+
moduleLoader = (0, _navios_di.inject)(_ModuleLoaderService);
|
|
5470
5464
|
httpApplication = null;
|
|
5471
|
-
logger = (0,
|
|
5472
|
-
container = (0,
|
|
5465
|
+
logger = (0, _navios_di.inject)(Logger, { context: _NaviosApplication.name });
|
|
5466
|
+
container = (0, _navios_di.inject)(_navios_di.Container);
|
|
5473
5467
|
appModule = null;
|
|
5474
5468
|
options = { adapter: [] };
|
|
5469
|
+
plugins = [];
|
|
5475
5470
|
/**
|
|
5476
5471
|
* Indicates whether the application has been initialized.
|
|
5477
5472
|
* Set to `true` after `init()` completes successfully.
|
|
@@ -5496,18 +5491,40 @@ _dec$14 = (0, __navios_di.Injectable)();
|
|
|
5496
5491
|
return this.container;
|
|
5497
5492
|
}
|
|
5498
5493
|
/**
|
|
5494
|
+
* Registers a plugin to be initialized after modules are loaded.
|
|
5495
|
+
*
|
|
5496
|
+
* Plugins are initialized in the order they are registered,
|
|
5497
|
+
* after all modules are loaded but before the server starts listening.
|
|
5498
|
+
*
|
|
5499
|
+
* @param definition - Plugin definition with options
|
|
5500
|
+
* @returns this for method chaining
|
|
5501
|
+
*
|
|
5502
|
+
* @example
|
|
5503
|
+
* ```typescript
|
|
5504
|
+
* import { defineOpenApiPlugin } from '@navios/openapi-fastify'
|
|
5505
|
+
*
|
|
5506
|
+
* app.usePlugin(defineOpenApiPlugin({
|
|
5507
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
5508
|
+
* }))
|
|
5509
|
+
* ```
|
|
5510
|
+
*/ usePlugin(definition) {
|
|
5511
|
+
this.plugins.push(definition);
|
|
5512
|
+
return this;
|
|
5513
|
+
}
|
|
5514
|
+
/**
|
|
5499
5515
|
* Initializes the application.
|
|
5500
|
-
*
|
|
5516
|
+
*
|
|
5501
5517
|
* This method:
|
|
5502
5518
|
* - Loads all modules and their dependencies
|
|
5503
5519
|
* - Sets up the HTTP server if an adapter is configured
|
|
5504
5520
|
* - Calls onModuleInit hooks on all modules
|
|
5521
|
+
* - Initializes registered plugins
|
|
5505
5522
|
* - Marks the application as initialized
|
|
5506
|
-
*
|
|
5523
|
+
*
|
|
5507
5524
|
* Must be called before `listen()`.
|
|
5508
|
-
*
|
|
5525
|
+
*
|
|
5509
5526
|
* @throws Error if app module is not set
|
|
5510
|
-
*
|
|
5527
|
+
*
|
|
5511
5528
|
* @example
|
|
5512
5529
|
* ```typescript
|
|
5513
5530
|
* const app = await NaviosFactory.create(AppModule, {
|
|
@@ -5521,6 +5538,7 @@ _dec$14 = (0, __navios_di.Injectable)();
|
|
|
5521
5538
|
await this.moduleLoader.loadModules(this.appModule);
|
|
5522
5539
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.setupHttpServer(this.options);
|
|
5523
5540
|
await this.initModules();
|
|
5541
|
+
await this.initPlugins();
|
|
5524
5542
|
if (this.environment.hasHttpSetup()) await this.httpApplication?.ready();
|
|
5525
5543
|
this.isInitialized = true;
|
|
5526
5544
|
this.logger.debug("Navios application initialized");
|
|
@@ -5529,6 +5547,19 @@ _dec$14 = (0, __navios_di.Injectable)();
|
|
|
5529
5547
|
const modules = this.moduleLoader.getAllModules();
|
|
5530
5548
|
await this.httpApplication?.onModulesInit(modules);
|
|
5531
5549
|
}
|
|
5550
|
+
async initPlugins() {
|
|
5551
|
+
if (this.plugins.length === 0) return;
|
|
5552
|
+
const context = {
|
|
5553
|
+
modules: this.moduleLoader.getAllModules(),
|
|
5554
|
+
server: this.httpApplication?.getServer() ?? null,
|
|
5555
|
+
container: this.container,
|
|
5556
|
+
globalPrefix: this.httpApplication?.getGlobalPrefix() ?? ""
|
|
5557
|
+
};
|
|
5558
|
+
for (const { plugin, options } of this.plugins) {
|
|
5559
|
+
this.logger.debug(`Initializing plugin: ${plugin.name}`);
|
|
5560
|
+
await plugin.register(context, options);
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5532
5563
|
/**
|
|
5533
5564
|
* Enables CORS (Cross-Origin Resource Sharing) for the application.
|
|
5534
5565
|
*
|
|
@@ -5700,7 +5731,7 @@ _dec$14 = (0, __navios_di.Injectable)();
|
|
|
5700
5731
|
* })
|
|
5701
5732
|
* ```
|
|
5702
5733
|
*/ static async create(appModule, options = { adapter: [] }) {
|
|
5703
|
-
const container = options.container ?? new
|
|
5734
|
+
const container = options.container ?? new _navios_di.Container();
|
|
5704
5735
|
await this.registerLoggerConfiguration(container, options);
|
|
5705
5736
|
const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
|
|
5706
5737
|
for (const adapter of adapters) await this.registerEnvironment(container, adapter);
|
|
@@ -5716,7 +5747,7 @@ _dec$14 = (0, __navios_di.Injectable)();
|
|
|
5716
5747
|
static async registerLoggerConfiguration(container, options) {
|
|
5717
5748
|
const { logger } = options;
|
|
5718
5749
|
if (Array.isArray(logger) || isNil(logger)) (await container.get(LoggerOutput))?.setup({ logLevels: logger });
|
|
5719
|
-
if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger,
|
|
5750
|
+
if (logger !== true && !isNil(logger)) container.getServiceLocator().getManager().storeCreatedHolder(LoggerOutput.toString(), logger, _navios_di.InjectableType.Class, _navios_di.InjectableScope.Singleton);
|
|
5720
5751
|
}
|
|
5721
5752
|
};
|
|
5722
5753
|
|
|
@@ -7711,10 +7742,10 @@ exports.requestIdStore = requestIdStore;
|
|
|
7711
7742
|
exports.runWithRequestId = runWithRequestId;
|
|
7712
7743
|
exports.stripEndSlash = stripEndSlash;
|
|
7713
7744
|
exports.yellow = yellow;
|
|
7714
|
-
Object.keys(
|
|
7745
|
+
Object.keys(_navios_di).forEach(function (k) {
|
|
7715
7746
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
7716
7747
|
enumerable: true,
|
|
7717
|
-
get: function () { return
|
|
7748
|
+
get: function () { return _navios_di[k]; }
|
|
7718
7749
|
});
|
|
7719
7750
|
});
|
|
7720
7751
|
|