@navios/core 0.1.2 → 0.1.4
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/dist/index.d.mts +54 -13
- package/dist/index.d.ts +54 -13
- package/dist/index.js +336 -203
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +336 -209
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config/config.provider.mts +10 -20
- package/src/decorators/endpoint.decorator.mts +7 -2
- package/src/decorators/header.decorator.mts +18 -0
- package/src/decorators/http-code.decorator.mts +18 -0
- package/src/decorators/index.mts +2 -0
- package/src/logger/logger.service.mts +0 -1
- package/src/logger/pino-wrapper.mts +6 -5
- package/src/metadata/endpoint.metadata.mts +13 -0
- package/src/navios.application.mts +36 -1
- package/src/service-locator/__tests__/injectable.spec.mts +2 -1
- package/src/service-locator/__tests__/injection-token.spec.mts +124 -0
- package/src/service-locator/decorators/get-injectable-token.mts +2 -6
- package/src/service-locator/decorators/injectable.decorator.mts +7 -46
- package/src/service-locator/errors/errors.enum.mts +1 -0
- package/src/service-locator/errors/factory-token-not-resolved.mts +10 -0
- package/src/service-locator/errors/index.mts +1 -0
- package/src/service-locator/index.mts +1 -0
- package/src/service-locator/inject.mts +4 -18
- package/src/service-locator/injection-token.mts +57 -6
- package/src/service-locator/resolve-service.mts +46 -0
- package/src/service-locator/service-locator.mts +87 -35
- package/src/service-locator/sync-injector.mts +0 -8
- package/src/services/controller-adapter.service.mts +116 -71
package/dist/index.js
CHANGED
|
@@ -77,9 +77,9 @@ __export(src_exports, {
|
|
|
77
77
|
Application: () => Application,
|
|
78
78
|
AttributeFactory: () => AttributeFactory,
|
|
79
79
|
BadRequestException: () => BadRequestException,
|
|
80
|
+
BoundInjectionToken: () => BoundInjectionToken,
|
|
80
81
|
ConfigProvider: () => ConfigProvider,
|
|
81
82
|
ConfigProviderFactory: () => ConfigProviderFactory,
|
|
82
|
-
ConfigProviderInjectionToken: () => ConfigProviderInjectionToken,
|
|
83
83
|
ConfigProviderOptions: () => ConfigProviderOptions,
|
|
84
84
|
ConfigServiceInstance: () => ConfigServiceInstance,
|
|
85
85
|
ConflictException: () => ConflictException,
|
|
@@ -89,14 +89,19 @@ __export(src_exports, {
|
|
|
89
89
|
ControllerMetadataKey: () => ControllerMetadataKey,
|
|
90
90
|
Endpoint: () => Endpoint,
|
|
91
91
|
EndpointMetadataKey: () => EndpointMetadataKey,
|
|
92
|
+
EndpointType: () => EndpointType,
|
|
92
93
|
ErrorsEnum: () => ErrorsEnum,
|
|
93
94
|
EventEmitter: () => EventEmitter,
|
|
94
95
|
ExecutionContext: () => ExecutionContext2,
|
|
95
96
|
ExecutionContextInjectionToken: () => ExecutionContextInjectionToken,
|
|
96
97
|
ExecutionContextToken: () => ExecutionContextToken,
|
|
98
|
+
FactoryInjectionToken: () => FactoryInjectionToken,
|
|
97
99
|
FactoryNotFound: () => FactoryNotFound,
|
|
100
|
+
FactoryTokenNotResolved: () => FactoryTokenNotResolved,
|
|
98
101
|
ForbiddenException: () => ForbiddenException,
|
|
99
102
|
GuardRunnerService: () => GuardRunnerService,
|
|
103
|
+
Header: () => Header,
|
|
104
|
+
HttpCode: () => HttpCode,
|
|
100
105
|
HttpException: () => HttpException,
|
|
101
106
|
Injectable: () => Injectable,
|
|
102
107
|
InjectableScope: () => InjectableScope,
|
|
@@ -158,10 +163,11 @@ __export(src_exports, {
|
|
|
158
163
|
isString: () => isString,
|
|
159
164
|
isSymbol: () => isSymbol,
|
|
160
165
|
isUndefined: () => isUndefined,
|
|
161
|
-
makeConfigToken: () => makeConfigToken,
|
|
162
166
|
normalizePath: () => normalizePath,
|
|
163
167
|
override: () => override,
|
|
168
|
+
provideConfig: () => provideConfig,
|
|
164
169
|
provideServiceLocator: () => provideServiceLocator,
|
|
170
|
+
resolveService: () => resolveService,
|
|
165
171
|
setPromiseCollector: () => setPromiseCollector,
|
|
166
172
|
stripEndSlash: () => stripEndSlash,
|
|
167
173
|
syncInject: () => syncInject,
|
|
@@ -280,6 +286,9 @@ var isSymbol = (val) => typeof val === "symbol";
|
|
|
280
286
|
// packages/core/src/logger/console-logger.service.mts
|
|
281
287
|
var import_util = require("util");
|
|
282
288
|
|
|
289
|
+
// packages/core/src/service-locator/decorators/injectable.decorator.mts
|
|
290
|
+
var import_common2 = require("@navios/common");
|
|
291
|
+
|
|
283
292
|
// packages/core/src/service-locator/enums/injectable-scope.enum.mts
|
|
284
293
|
var InjectableScope = /* @__PURE__ */ ((InjectableScope2) => {
|
|
285
294
|
InjectableScope2["Singleton"] = "Singleton";
|
|
@@ -299,8 +308,38 @@ var InjectionToken = class _InjectionToken {
|
|
|
299
308
|
static create(name2, schema) {
|
|
300
309
|
return new _InjectionToken(name2, schema);
|
|
301
310
|
}
|
|
302
|
-
|
|
303
|
-
return
|
|
311
|
+
static bound(token, value) {
|
|
312
|
+
return new BoundInjectionToken(token, value);
|
|
313
|
+
}
|
|
314
|
+
static factory(token, factory) {
|
|
315
|
+
return new FactoryInjectionToken(token, factory);
|
|
316
|
+
}
|
|
317
|
+
static refineType(token) {
|
|
318
|
+
return token;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var BoundInjectionToken = class extends InjectionToken {
|
|
322
|
+
constructor(token, value) {
|
|
323
|
+
super(token.name, token.schema);
|
|
324
|
+
this.token = token;
|
|
325
|
+
this.value = value;
|
|
326
|
+
this.id = token.id;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var FactoryInjectionToken = class extends InjectionToken {
|
|
330
|
+
constructor(token, factory) {
|
|
331
|
+
super(token.name, token.schema);
|
|
332
|
+
this.token = token;
|
|
333
|
+
this.factory = factory;
|
|
334
|
+
}
|
|
335
|
+
value;
|
|
336
|
+
resolved = false;
|
|
337
|
+
async resolve() {
|
|
338
|
+
if (!this.value) {
|
|
339
|
+
this.value = await this.factory();
|
|
340
|
+
this.resolved = true;
|
|
341
|
+
}
|
|
342
|
+
return this.value;
|
|
304
343
|
}
|
|
305
344
|
};
|
|
306
345
|
|
|
@@ -311,6 +350,7 @@ var ErrorsEnum = /* @__PURE__ */ ((ErrorsEnum2) => {
|
|
|
311
350
|
ErrorsEnum2["InstanceDestroying"] = "InstanceDestroying";
|
|
312
351
|
ErrorsEnum2["UnknownError"] = "UnknownError";
|
|
313
352
|
ErrorsEnum2["FactoryNotFound"] = "FactoryNotFound";
|
|
353
|
+
ErrorsEnum2["FactoryTokenNotResolved"] = "FactoryTokenNotResolved";
|
|
314
354
|
return ErrorsEnum2;
|
|
315
355
|
})(ErrorsEnum || {});
|
|
316
356
|
|
|
@@ -323,6 +363,14 @@ var FactoryNotFound = class extends Error {
|
|
|
323
363
|
code = "FactoryNotFound" /* FactoryNotFound */;
|
|
324
364
|
};
|
|
325
365
|
|
|
366
|
+
// packages/core/src/service-locator/errors/factory-token-not-resolved.mts
|
|
367
|
+
var FactoryTokenNotResolved = class extends Error {
|
|
368
|
+
code = "FactoryTokenNotResolved" /* FactoryTokenNotResolved */;
|
|
369
|
+
constructor(name2) {
|
|
370
|
+
super(`Factory token not resolved: ${name2.toString()}`);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
|
|
326
374
|
// packages/core/src/service-locator/errors/instance-destroying.mts
|
|
327
375
|
var InstanceDestroying = class extends Error {
|
|
328
376
|
constructor(name2) {
|
|
@@ -565,29 +613,48 @@ var ServiceLocator = class {
|
|
|
565
613
|
this.instanceFactories.delete(token);
|
|
566
614
|
}
|
|
567
615
|
}
|
|
568
|
-
|
|
569
|
-
var _a;
|
|
570
|
-
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
616
|
+
resolveTokenArgs(token, args) {
|
|
617
|
+
var _a, _b;
|
|
618
|
+
let realArgs = args;
|
|
619
|
+
if (token instanceof BoundInjectionToken) {
|
|
620
|
+
realArgs = token.value;
|
|
621
|
+
} else if (token instanceof FactoryInjectionToken) {
|
|
622
|
+
if (token.resolved) {
|
|
623
|
+
realArgs = token.value;
|
|
624
|
+
} else {
|
|
625
|
+
return [new FactoryTokenNotResolved(token.name)];
|
|
626
|
+
}
|
|
577
627
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
const validatedArgs = token.schema ? token.schema.safeParse(args) : void 0;
|
|
628
|
+
if (!token.schema) {
|
|
629
|
+
return [void 0, realArgs];
|
|
630
|
+
}
|
|
631
|
+
const validatedArgs = (_a = token.schema) == null ? void 0 : _a.safeParse(realArgs);
|
|
583
632
|
if (validatedArgs && !validatedArgs.success) {
|
|
584
|
-
(
|
|
633
|
+
(_b = this.logger) == null ? void 0 : _b.error(
|
|
585
634
|
`[ServiceLocator]#getInstance(): Error validating args for ${token.name.toString()}`,
|
|
586
635
|
validatedArgs.error
|
|
587
636
|
);
|
|
588
637
|
return [new UnknownError(validatedArgs.error)];
|
|
589
638
|
}
|
|
590
|
-
|
|
639
|
+
return [void 0, validatedArgs == null ? void 0 : validatedArgs.data];
|
|
640
|
+
}
|
|
641
|
+
getInstanceIdentifier(token, args) {
|
|
642
|
+
const [err, realArgs] = this.resolveTokenArgs(token, args);
|
|
643
|
+
if (err) {
|
|
644
|
+
throw err;
|
|
645
|
+
}
|
|
646
|
+
return this.makeInstanceName(token, realArgs);
|
|
647
|
+
}
|
|
648
|
+
async getInstance(token, args) {
|
|
649
|
+
var _a, _b;
|
|
650
|
+
const [err, realArgs] = this.resolveTokenArgs(token, args);
|
|
651
|
+
if (err instanceof UnknownError) {
|
|
652
|
+
throw err;
|
|
653
|
+
} else if (err instanceof FactoryTokenNotResolved && token instanceof FactoryInjectionToken) {
|
|
654
|
+
await token.resolve();
|
|
655
|
+
return this.getInstance(token, args);
|
|
656
|
+
}
|
|
657
|
+
const instanceName = this.makeInstanceName(token, realArgs);
|
|
591
658
|
const [error, holder] = this.manager.get(instanceName);
|
|
592
659
|
if (!error) {
|
|
593
660
|
if (holder.status === "creating" /* Creating */) {
|
|
@@ -599,13 +666,13 @@ var ServiceLocator = class {
|
|
|
599
666
|
}
|
|
600
667
|
switch (error.code) {
|
|
601
668
|
case "InstanceDestroying" /* InstanceDestroying */:
|
|
602
|
-
(
|
|
669
|
+
(_a = this.logger) == null ? void 0 : _a.log(
|
|
603
670
|
`[ServiceLocator]#getInstance() TTL expired for ${holder == null ? void 0 : holder.name}`
|
|
604
671
|
);
|
|
605
672
|
await (holder == null ? void 0 : holder.destroyPromise);
|
|
606
673
|
return this.getInstance(token, args);
|
|
607
674
|
case "InstanceExpired" /* InstanceExpired */:
|
|
608
|
-
(
|
|
675
|
+
(_b = this.logger) == null ? void 0 : _b.log(
|
|
609
676
|
`[ServiceLocator]#getInstance() TTL expired for ${holder == null ? void 0 : holder.name}`
|
|
610
677
|
);
|
|
611
678
|
await this.invalidate(instanceName);
|
|
@@ -615,7 +682,7 @@ var ServiceLocator = class {
|
|
|
615
682
|
default:
|
|
616
683
|
return [error];
|
|
617
684
|
}
|
|
618
|
-
return this.createInstance(instanceName, token,
|
|
685
|
+
return this.createInstance(instanceName, token, realArgs);
|
|
619
686
|
}
|
|
620
687
|
async getOrThrowInstance(token, args) {
|
|
621
688
|
const [error, instance] = await this.getInstance(token, args);
|
|
@@ -636,10 +703,15 @@ var ServiceLocator = class {
|
|
|
636
703
|
(_a = this.logger) == null ? void 0 : _a.log(
|
|
637
704
|
`[ServiceLocator]#createInstance() Creating instance for ${instanceName}`
|
|
638
705
|
);
|
|
639
|
-
|
|
640
|
-
|
|
706
|
+
let realToken = token instanceof BoundInjectionToken || token instanceof FactoryInjectionToken ? token.token : token;
|
|
707
|
+
if (this.abstractFactories.has(realToken) || this.instanceFactories.has(realToken)) {
|
|
708
|
+
return this.createInstanceFromAbstractFactory(
|
|
709
|
+
instanceName,
|
|
710
|
+
realToken,
|
|
711
|
+
args
|
|
712
|
+
);
|
|
641
713
|
} else {
|
|
642
|
-
return [new FactoryNotFound(
|
|
714
|
+
return [new FactoryNotFound(realToken.name.toString())];
|
|
643
715
|
}
|
|
644
716
|
}
|
|
645
717
|
async createInstanceFromAbstractFactory(instanceName, token, args) {
|
|
@@ -686,7 +758,7 @@ var ServiceLocator = class {
|
|
|
686
758
|
);
|
|
687
759
|
});
|
|
688
760
|
}
|
|
689
|
-
if (holder.ttl === 0) {
|
|
761
|
+
if (holder.ttl === 0 || !shouldStore) {
|
|
690
762
|
await this.invalidate(instanceName);
|
|
691
763
|
}
|
|
692
764
|
await this.notifyListeners(instanceName);
|
|
@@ -758,16 +830,11 @@ var ServiceLocator = class {
|
|
|
758
830
|
};
|
|
759
831
|
}
|
|
760
832
|
getSyncInstance(token, args) {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
(_a = this.logger) == null ? void 0 : _a.error(
|
|
765
|
-
`[ServiceLocator]#getInstance(): Error validating args for ${token.name.toString()}`,
|
|
766
|
-
validatedArgs.error
|
|
767
|
-
);
|
|
768
|
-
throw new UnknownError(validatedArgs.error);
|
|
833
|
+
const [err, realArgs] = this.resolveTokenArgs(token, args);
|
|
834
|
+
if (err) {
|
|
835
|
+
return null;
|
|
769
836
|
}
|
|
770
|
-
const instanceName = this.makeInstanceName(token,
|
|
837
|
+
const instanceName = this.makeInstanceName(token, realArgs);
|
|
771
838
|
const [error, holder] = this.manager.get(instanceName);
|
|
772
839
|
if (error) {
|
|
773
840
|
return null;
|
|
@@ -875,6 +942,9 @@ function getServiceLocator() {
|
|
|
875
942
|
return serviceLocator;
|
|
876
943
|
}
|
|
877
944
|
|
|
945
|
+
// packages/core/src/service-locator/resolve-service.mts
|
|
946
|
+
var import_common = require("@navios/common");
|
|
947
|
+
|
|
878
948
|
// packages/core/src/service-locator/proxy-service-locator.mts
|
|
879
949
|
var ProxyServiceLocator = class {
|
|
880
950
|
constructor(serviceLocator2, ctx) {
|
|
@@ -923,14 +993,6 @@ function makeProxyServiceLocator(serviceLocator2, ctx) {
|
|
|
923
993
|
// packages/core/src/service-locator/sync-injector.mts
|
|
924
994
|
var promiseCollector = null;
|
|
925
995
|
function syncInject(token, args) {
|
|
926
|
-
if (token.schema) {
|
|
927
|
-
const parsed = token.schema.safeParse(args);
|
|
928
|
-
if (!parsed.success) {
|
|
929
|
-
throw new Error(
|
|
930
|
-
`[ServiceLocator] Invalid arguments for ${token.name.toString()}: ${parsed.error}`
|
|
931
|
-
);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
996
|
let realToken = token;
|
|
935
997
|
if (!(token instanceof InjectionToken)) {
|
|
936
998
|
realToken = getInjectableToken(token);
|
|
@@ -954,6 +1016,40 @@ function setPromiseCollector(collector) {
|
|
|
954
1016
|
return original;
|
|
955
1017
|
}
|
|
956
1018
|
|
|
1019
|
+
// packages/core/src/service-locator/resolve-service.mts
|
|
1020
|
+
async function resolveService(ctx, target, args = []) {
|
|
1021
|
+
const proxyServiceLocator = makeProxyServiceLocator(getServiceLocator(), ctx);
|
|
1022
|
+
let promises = [];
|
|
1023
|
+
const promiseCollector2 = (promise) => {
|
|
1024
|
+
promises.push(promise);
|
|
1025
|
+
};
|
|
1026
|
+
const originalPromiseCollector = setPromiseCollector(promiseCollector2);
|
|
1027
|
+
const tryLoad = () => {
|
|
1028
|
+
const original = provideServiceLocator(proxyServiceLocator);
|
|
1029
|
+
let result = new target(...args);
|
|
1030
|
+
provideServiceLocator(original);
|
|
1031
|
+
return result;
|
|
1032
|
+
};
|
|
1033
|
+
let instance = tryLoad();
|
|
1034
|
+
setPromiseCollector(originalPromiseCollector);
|
|
1035
|
+
if (promises.length > 0) {
|
|
1036
|
+
await Promise.all(promises);
|
|
1037
|
+
promises = [];
|
|
1038
|
+
instance = tryLoad();
|
|
1039
|
+
}
|
|
1040
|
+
if (promises.length > 0) {
|
|
1041
|
+
console.error(`[ServiceLocator] ${target.name} has problem with it's definition.
|
|
1042
|
+
|
|
1043
|
+
One or more of the dependencies are registered as a InjectableScope.Instance and are used with syncInject.
|
|
1044
|
+
|
|
1045
|
+
Please use inject instead of syncInject to load those dependencies.`);
|
|
1046
|
+
throw new import_common.NaviosException(
|
|
1047
|
+
`[ServiceLocator] Service ${target.name} cannot be instantiated.`
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
return instance;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
957
1053
|
// packages/core/src/service-locator/decorators/injectable.decorator.mts
|
|
958
1054
|
var InjectableType = /* @__PURE__ */ ((InjectableType2) => {
|
|
959
1055
|
InjectableType2["Class"] = "Class";
|
|
@@ -974,62 +1070,22 @@ function Injectable({
|
|
|
974
1070
|
}
|
|
975
1071
|
let injectableToken = token ?? InjectionToken.create(target);
|
|
976
1072
|
const locator = getServiceLocator();
|
|
977
|
-
if (!locator) {
|
|
978
|
-
throw new Error(
|
|
979
|
-
"[ServiceLocator] Service locator is not initialized. Please provide the service locator before using the @Injectable decorator."
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
1073
|
if (type === "Class" /* Class */) {
|
|
983
1074
|
locator.registerAbstractFactory(
|
|
984
1075
|
injectableToken,
|
|
985
|
-
async (ctx) =>
|
|
986
|
-
if (scope === "Instance" /* Instance */) {
|
|
987
|
-
ctx.setTtl(0);
|
|
988
|
-
}
|
|
989
|
-
const proxyServiceLocator = makeProxyServiceLocator(
|
|
990
|
-
getServiceLocator(),
|
|
991
|
-
ctx
|
|
992
|
-
);
|
|
993
|
-
const promises = [];
|
|
994
|
-
const promiseCollector2 = (promise) => {
|
|
995
|
-
promises.push(promise);
|
|
996
|
-
};
|
|
997
|
-
const originalPromiseCollector = setPromiseCollector(promiseCollector2);
|
|
998
|
-
const tryInit = () => {
|
|
999
|
-
const original = provideServiceLocator(proxyServiceLocator);
|
|
1000
|
-
let result2 = new target();
|
|
1001
|
-
provideServiceLocator(original);
|
|
1002
|
-
return result2;
|
|
1003
|
-
};
|
|
1004
|
-
const result = tryInit();
|
|
1005
|
-
setPromiseCollector(originalPromiseCollector);
|
|
1006
|
-
if (promises.length > 0) {
|
|
1007
|
-
await Promise.all(promises);
|
|
1008
|
-
return tryInit();
|
|
1009
|
-
}
|
|
1010
|
-
return result;
|
|
1011
|
-
},
|
|
1076
|
+
async (ctx) => resolveService(ctx, target),
|
|
1012
1077
|
scope
|
|
1013
1078
|
);
|
|
1014
1079
|
} else if (type === "Factory" /* Factory */) {
|
|
1015
1080
|
locator.registerAbstractFactory(
|
|
1016
1081
|
injectableToken,
|
|
1017
1082
|
async (ctx, args) => {
|
|
1018
|
-
|
|
1019
|
-
ctx.setTtl(0);
|
|
1020
|
-
}
|
|
1021
|
-
const proxyServiceLocator = makeProxyServiceLocator(
|
|
1022
|
-
getServiceLocator(),
|
|
1023
|
-
ctx
|
|
1024
|
-
);
|
|
1025
|
-
const original = provideServiceLocator(proxyServiceLocator);
|
|
1026
|
-
const builder = new target();
|
|
1083
|
+
const builder = await resolveService(ctx, target);
|
|
1027
1084
|
if (typeof builder.create !== "function") {
|
|
1028
|
-
throw new
|
|
1085
|
+
throw new import_common2.NaviosException(
|
|
1029
1086
|
`[ServiceLocator] Factory ${target.name} does not implement the create method.`
|
|
1030
1087
|
);
|
|
1031
1088
|
}
|
|
1032
|
-
provideServiceLocator(original);
|
|
1033
1089
|
return builder.create(ctx, args);
|
|
1034
1090
|
},
|
|
1035
1091
|
scope
|
|
@@ -1092,14 +1148,6 @@ var EventEmitter = class {
|
|
|
1092
1148
|
|
|
1093
1149
|
// packages/core/src/service-locator/inject.mts
|
|
1094
1150
|
function inject(token, args) {
|
|
1095
|
-
if (token.schema) {
|
|
1096
|
-
const parsed = token.schema.safeParse(args);
|
|
1097
|
-
if (!parsed.success) {
|
|
1098
|
-
throw new Error(
|
|
1099
|
-
`[ServiceLocator] Invalid arguments for ${token.name.toString()}: ${parsed.error}`
|
|
1100
|
-
);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
1151
|
let realToken = token;
|
|
1104
1152
|
if (!(token instanceof InjectionToken)) {
|
|
1105
1153
|
realToken = getInjectableToken(token);
|
|
@@ -1567,7 +1615,6 @@ var _LoggerInstance = class _LoggerInstance {
|
|
|
1567
1615
|
}
|
|
1568
1616
|
static overrideLogger(logger) {
|
|
1569
1617
|
var _a, _b;
|
|
1570
|
-
console.log(logger);
|
|
1571
1618
|
if (Array.isArray(logger)) {
|
|
1572
1619
|
_LoggerInstance.logLevels = logger;
|
|
1573
1620
|
return (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.setLogLevels) == null ? void 0 : _b.call(_a, logger);
|
|
@@ -1639,8 +1686,7 @@ var PinoWrapper = class _PinoWrapper {
|
|
|
1639
1686
|
warn(message, ...optionalParams) {
|
|
1640
1687
|
this.logger.warn(message, ...optionalParams);
|
|
1641
1688
|
}
|
|
1642
|
-
info(
|
|
1643
|
-
this.logger.log(message, ...optionalParams);
|
|
1689
|
+
info() {
|
|
1644
1690
|
}
|
|
1645
1691
|
debug(message, ...optionalParams) {
|
|
1646
1692
|
var _a, _b;
|
|
@@ -1650,7 +1696,7 @@ var PinoWrapper = class _PinoWrapper {
|
|
|
1650
1696
|
var _a, _b;
|
|
1651
1697
|
(_b = (_a = this.logger).verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1652
1698
|
}
|
|
1653
|
-
silent(
|
|
1699
|
+
silent() {
|
|
1654
1700
|
}
|
|
1655
1701
|
child(options) {
|
|
1656
1702
|
const keys = Object.keys(options);
|
|
@@ -1669,14 +1715,14 @@ var PinoWrapper = class _PinoWrapper {
|
|
|
1669
1715
|
}
|
|
1670
1716
|
const levels = LoggerInstance["logLevels"];
|
|
1671
1717
|
if (levels) {
|
|
1672
|
-
return levels
|
|
1718
|
+
return levels.find((level) => level !== "verbose");
|
|
1673
1719
|
}
|
|
1674
|
-
return "
|
|
1720
|
+
return "warn";
|
|
1675
1721
|
}
|
|
1676
1722
|
};
|
|
1677
1723
|
|
|
1678
1724
|
// packages/core/src/config/config.service.mts
|
|
1679
|
-
var
|
|
1725
|
+
var import_common3 = require("@navios/common");
|
|
1680
1726
|
var ConfigServiceInstance = class {
|
|
1681
1727
|
constructor(config = {}, logger) {
|
|
1682
1728
|
this.config = config;
|
|
@@ -1715,30 +1761,29 @@ var ConfigServiceInstance = class {
|
|
|
1715
1761
|
if (value === null) {
|
|
1716
1762
|
const message = errorMessage || `Configuration value for key "${String(key)}" is not defined`;
|
|
1717
1763
|
this.logger.error(message);
|
|
1718
|
-
throw new
|
|
1764
|
+
throw new import_common3.NaviosException(message);
|
|
1719
1765
|
}
|
|
1720
1766
|
return value;
|
|
1721
1767
|
}
|
|
1722
1768
|
};
|
|
1723
1769
|
|
|
1724
1770
|
// packages/core/src/config/config.provider.mts
|
|
1725
|
-
var ConfigProviderInjectionToken = "ConfigProvider";
|
|
1726
1771
|
var ConfigProviderOptions = import_zod3.z.object({
|
|
1727
1772
|
load: import_zod3.z.function()
|
|
1728
1773
|
});
|
|
1729
|
-
var ConfigProvider = InjectionToken.create(
|
|
1774
|
+
var ConfigProvider = InjectionToken.create(ConfigServiceInstance, ConfigProviderOptions);
|
|
1730
1775
|
var _ConfigProviderFactory_decorators, _init4;
|
|
1731
1776
|
_ConfigProviderFactory_decorators = [Injectable({
|
|
1732
1777
|
token: ConfigProvider,
|
|
1733
1778
|
type: "Factory" /* Factory */
|
|
1734
1779
|
})];
|
|
1735
1780
|
var ConfigProviderFactory = class {
|
|
1736
|
-
logger =
|
|
1781
|
+
logger = syncInject(Logger, {
|
|
1737
1782
|
context: "ConfigService"
|
|
1738
1783
|
});
|
|
1739
1784
|
async create(ctx, args) {
|
|
1740
1785
|
const { load } = args;
|
|
1741
|
-
const logger =
|
|
1786
|
+
const logger = this.logger;
|
|
1742
1787
|
try {
|
|
1743
1788
|
const config = await load();
|
|
1744
1789
|
return new ConfigServiceInstance(config, logger);
|
|
@@ -1751,25 +1796,18 @@ var ConfigProviderFactory = class {
|
|
|
1751
1796
|
_init4 = __decoratorStart(null);
|
|
1752
1797
|
ConfigProviderFactory = __decorateElement(_init4, 0, "ConfigProviderFactory", _ConfigProviderFactory_decorators, ConfigProviderFactory);
|
|
1753
1798
|
__runInitializers(_init4, 1, ConfigProviderFactory);
|
|
1754
|
-
function
|
|
1755
|
-
|
|
1756
|
-
_ConfigServiceImpl_decorators = [Injectable({
|
|
1757
|
-
type: "Factory" /* Factory */
|
|
1758
|
-
})];
|
|
1759
|
-
class ConfigServiceImpl {
|
|
1760
|
-
configService = inject(ConfigProvider, options);
|
|
1761
|
-
create() {
|
|
1762
|
-
return this.configService;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
_init9 = __decoratorStart(null);
|
|
1766
|
-
ConfigServiceImpl = __decorateElement(_init9, 0, "ConfigServiceImpl", _ConfigServiceImpl_decorators, ConfigServiceImpl);
|
|
1767
|
-
__runInitializers(_init9, 1, ConfigServiceImpl);
|
|
1768
|
-
return getInjectableToken(ConfigServiceImpl);
|
|
1799
|
+
function provideConfig(options) {
|
|
1800
|
+
return InjectionToken.bound(ConfigProvider, options);
|
|
1769
1801
|
}
|
|
1770
1802
|
|
|
1771
1803
|
// packages/core/src/metadata/endpoint.metadata.mts
|
|
1772
1804
|
var EndpointMetadataKey = Symbol("EndpointMetadataKey");
|
|
1805
|
+
var EndpointType = /* @__PURE__ */ ((EndpointType2) => {
|
|
1806
|
+
EndpointType2["Unknown"] = "unknown";
|
|
1807
|
+
EndpointType2["Config"] = "config";
|
|
1808
|
+
EndpointType2["Handler"] = "handler";
|
|
1809
|
+
return EndpointType2;
|
|
1810
|
+
})(EndpointType || {});
|
|
1773
1811
|
function getAllEndpointMetadata(context) {
|
|
1774
1812
|
if (context.metadata) {
|
|
1775
1813
|
const metadata = context.metadata[EndpointMetadataKey];
|
|
@@ -1795,6 +1833,9 @@ function getEndpointMetadata(target, context) {
|
|
|
1795
1833
|
const newMetadata = {
|
|
1796
1834
|
classMethod: target.name,
|
|
1797
1835
|
url: "",
|
|
1836
|
+
successStatusCode: 200,
|
|
1837
|
+
headers: {},
|
|
1838
|
+
type: "unknown" /* Unknown */,
|
|
1798
1839
|
httpMethod: "GET",
|
|
1799
1840
|
config: null,
|
|
1800
1841
|
guards: /* @__PURE__ */ new Set(),
|
|
@@ -1924,6 +1965,7 @@ function Endpoint(endpoint) {
|
|
|
1924
1965
|
);
|
|
1925
1966
|
}
|
|
1926
1967
|
endpointMetadata.config = config;
|
|
1968
|
+
endpointMetadata.type = "config" /* Config */;
|
|
1927
1969
|
endpointMetadata.classMethod = target.name;
|
|
1928
1970
|
endpointMetadata.httpMethod = config.method;
|
|
1929
1971
|
endpointMetadata.url = config.url;
|
|
@@ -1932,6 +1974,32 @@ function Endpoint(endpoint) {
|
|
|
1932
1974
|
};
|
|
1933
1975
|
}
|
|
1934
1976
|
|
|
1977
|
+
// packages/core/src/decorators/header.decorator.mts
|
|
1978
|
+
function Header(name2, value) {
|
|
1979
|
+
return (target, context) => {
|
|
1980
|
+
if (context.kind !== "method") {
|
|
1981
|
+
throw new Error("[Navios] Header decorator can only be used on methods.");
|
|
1982
|
+
}
|
|
1983
|
+
const metadata = getEndpointMetadata(target, context);
|
|
1984
|
+
metadata.headers[name2] = value;
|
|
1985
|
+
return target;
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// packages/core/src/decorators/http-code.decorator.mts
|
|
1990
|
+
function HttpCode(code) {
|
|
1991
|
+
return (target, context) => {
|
|
1992
|
+
if (context.kind !== "method") {
|
|
1993
|
+
throw new Error(
|
|
1994
|
+
"[Navios] HttpCode decorator can only be used on methods."
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
const metadata = getEndpointMetadata(target, context);
|
|
1998
|
+
metadata.successStatusCode = code;
|
|
1999
|
+
return target;
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
|
|
1935
2003
|
// packages/core/src/decorators/module.decorator.mts
|
|
1936
2004
|
function Module(metadata) {
|
|
1937
2005
|
return (target, context) => {
|
|
@@ -2041,6 +2109,9 @@ var ConflictException = class extends HttpException {
|
|
|
2041
2109
|
}
|
|
2042
2110
|
};
|
|
2043
2111
|
|
|
2112
|
+
// packages/core/src/services/controller-adapter.service.mts
|
|
2113
|
+
var import_common4 = require("@navios/common");
|
|
2114
|
+
|
|
2044
2115
|
// packages/core/src/tokens/application.token.mts
|
|
2045
2116
|
var ApplicationInjectionToken = "ApplicationInjectionToken";
|
|
2046
2117
|
var Application = InjectionToken.create(
|
|
@@ -2184,8 +2255,8 @@ var _ControllerAdapterService = class _ControllerAdapterService {
|
|
|
2184
2255
|
setupController(controller, instance, moduleMetadata) {
|
|
2185
2256
|
const controllerMetadata = extractControllerMetadata(controller);
|
|
2186
2257
|
for (const endpoint of controllerMetadata.endpoints) {
|
|
2187
|
-
const { classMethod, url, httpMethod
|
|
2188
|
-
if (!url
|
|
2258
|
+
const { classMethod, url, httpMethod } = endpoint;
|
|
2259
|
+
if (!url) {
|
|
2189
2260
|
throw new Error(
|
|
2190
2261
|
`[Navios] Malformed Endpoint ${controller.name}:${classMethod}`
|
|
2191
2262
|
);
|
|
@@ -2195,91 +2266,115 @@ var _ControllerAdapterService = class _ControllerAdapterService {
|
|
|
2195
2266
|
controllerMetadata,
|
|
2196
2267
|
endpoint
|
|
2197
2268
|
);
|
|
2198
|
-
const guards = this.guardRunner.makeContext(executionContext);
|
|
2199
|
-
const { querySchema, requestSchema, responseSchema } = config;
|
|
2200
|
-
const schema = {};
|
|
2201
|
-
if (querySchema) {
|
|
2202
|
-
schema.querystring = querySchema;
|
|
2203
|
-
}
|
|
2204
|
-
if (requestSchema) {
|
|
2205
|
-
schema.body = requestSchema;
|
|
2206
|
-
}
|
|
2207
|
-
if (responseSchema) {
|
|
2208
|
-
schema.response = {
|
|
2209
|
-
200: responseSchema
|
|
2210
|
-
};
|
|
2211
|
-
}
|
|
2212
2269
|
instance.withTypeProvider().route({
|
|
2213
2270
|
method: httpMethod,
|
|
2214
2271
|
url: url.replaceAll("$", ":"),
|
|
2215
|
-
schema,
|
|
2216
|
-
preHandler:
|
|
2217
|
-
|
|
2218
|
-
getServiceLocator().registerInstance(Request, request);
|
|
2219
|
-
getServiceLocator().registerInstance(Reply, reply);
|
|
2220
|
-
getServiceLocator().registerInstance(
|
|
2221
|
-
ExecutionContextToken,
|
|
2222
|
-
executionContext
|
|
2223
|
-
);
|
|
2224
|
-
executionContext.provideRequest(request);
|
|
2225
|
-
executionContext.provideReply(reply);
|
|
2226
|
-
const canActivate = await this.guardRunner.runGuards(
|
|
2227
|
-
guards,
|
|
2228
|
-
executionContext
|
|
2229
|
-
);
|
|
2230
|
-
getServiceLocator().removeInstance(Request);
|
|
2231
|
-
getServiceLocator().removeInstance(Reply);
|
|
2232
|
-
getServiceLocator().removeInstance(ExecutionContextToken);
|
|
2233
|
-
if (!canActivate) {
|
|
2234
|
-
return reply;
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
},
|
|
2238
|
-
handler: async (request, reply) => {
|
|
2239
|
-
getServiceLocator().registerInstance(Request, request);
|
|
2240
|
-
getServiceLocator().registerInstance(Reply, reply);
|
|
2241
|
-
getServiceLocator().registerInstance(
|
|
2242
|
-
ExecutionContextToken,
|
|
2243
|
-
executionContext
|
|
2244
|
-
);
|
|
2245
|
-
executionContext.provideRequest(request);
|
|
2246
|
-
executionContext.provideReply(reply);
|
|
2247
|
-
const controllerInstance = await inject(controller);
|
|
2248
|
-
try {
|
|
2249
|
-
const { query, params, body } = request;
|
|
2250
|
-
const argument = {};
|
|
2251
|
-
if (query && Object.keys(query).length > 0) {
|
|
2252
|
-
argument.params = query;
|
|
2253
|
-
}
|
|
2254
|
-
if (params && Object.keys(params).length > 0) {
|
|
2255
|
-
argument.urlParams = params;
|
|
2256
|
-
}
|
|
2257
|
-
if (body) {
|
|
2258
|
-
argument.data = body;
|
|
2259
|
-
}
|
|
2260
|
-
const result = await controllerInstance[classMethod](argument);
|
|
2261
|
-
reply.status(200).send(result);
|
|
2262
|
-
} catch (error) {
|
|
2263
|
-
if (error instanceof HttpException) {
|
|
2264
|
-
reply.status(error.statusCode).send(error.response);
|
|
2265
|
-
} else {
|
|
2266
|
-
reply.status(500).send({
|
|
2267
|
-
message: "Internal server error",
|
|
2268
|
-
error: error.message
|
|
2269
|
-
});
|
|
2270
|
-
}
|
|
2271
|
-
} finally {
|
|
2272
|
-
getServiceLocator().removeInstance(Request);
|
|
2273
|
-
getServiceLocator().removeInstance(Reply);
|
|
2274
|
-
getServiceLocator().removeInstance(ExecutionContextToken);
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2272
|
+
schema: this.provideSchemaForConfig(endpoint),
|
|
2273
|
+
preHandler: this.providePreHandler(executionContext),
|
|
2274
|
+
handler: this.provideHandler(controller, executionContext, endpoint)
|
|
2277
2275
|
});
|
|
2278
2276
|
this.logger.debug(
|
|
2279
2277
|
`Registered ${httpMethod} ${url} for ${controller.name}:${classMethod}`
|
|
2280
2278
|
);
|
|
2281
2279
|
}
|
|
2282
2280
|
}
|
|
2281
|
+
providePreHandler(executionContext) {
|
|
2282
|
+
const guards = this.guardRunner.makeContext(executionContext);
|
|
2283
|
+
return guards.size > 0 ? async (request, reply) => {
|
|
2284
|
+
getServiceLocator().registerInstance(Request, request);
|
|
2285
|
+
getServiceLocator().registerInstance(Reply, reply);
|
|
2286
|
+
getServiceLocator().registerInstance(
|
|
2287
|
+
ExecutionContextToken,
|
|
2288
|
+
executionContext
|
|
2289
|
+
);
|
|
2290
|
+
executionContext.provideRequest(request);
|
|
2291
|
+
executionContext.provideReply(reply);
|
|
2292
|
+
let canActivate = true;
|
|
2293
|
+
try {
|
|
2294
|
+
canActivate = await this.guardRunner.runGuards(
|
|
2295
|
+
guards,
|
|
2296
|
+
executionContext
|
|
2297
|
+
);
|
|
2298
|
+
} finally {
|
|
2299
|
+
getServiceLocator().removeInstance(Request);
|
|
2300
|
+
getServiceLocator().removeInstance(Reply);
|
|
2301
|
+
getServiceLocator().removeInstance(ExecutionContextToken);
|
|
2302
|
+
}
|
|
2303
|
+
if (!canActivate) {
|
|
2304
|
+
return reply;
|
|
2305
|
+
}
|
|
2306
|
+
} : void 0;
|
|
2307
|
+
}
|
|
2308
|
+
provideSchemaForConfig(endpointMetadata) {
|
|
2309
|
+
if (!endpointMetadata.config) {
|
|
2310
|
+
this.logger.warn(`No config found for endpoint ${endpointMetadata.url}`);
|
|
2311
|
+
return {};
|
|
2312
|
+
}
|
|
2313
|
+
const { querySchema, requestSchema, responseSchema } = endpointMetadata.config;
|
|
2314
|
+
const schema = {};
|
|
2315
|
+
if (querySchema) {
|
|
2316
|
+
schema.querystring = querySchema;
|
|
2317
|
+
}
|
|
2318
|
+
if (requestSchema) {
|
|
2319
|
+
schema.body = requestSchema;
|
|
2320
|
+
}
|
|
2321
|
+
if (responseSchema) {
|
|
2322
|
+
schema.response = {
|
|
2323
|
+
200: responseSchema
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
return schema;
|
|
2327
|
+
}
|
|
2328
|
+
provideHandler(controller, executionContext, endpointMetadata) {
|
|
2329
|
+
switch (endpointMetadata.type) {
|
|
2330
|
+
case "unknown" /* Unknown */:
|
|
2331
|
+
this.logger.error(
|
|
2332
|
+
`Unknown endpoint type ${endpointMetadata.type} for ${controller.name}:${endpointMetadata.classMethod}`
|
|
2333
|
+
);
|
|
2334
|
+
throw new import_common4.NaviosException("Unknown endpoint type");
|
|
2335
|
+
case "config" /* Config */:
|
|
2336
|
+
return this.provideHandlerForConfig(
|
|
2337
|
+
controller,
|
|
2338
|
+
executionContext,
|
|
2339
|
+
endpointMetadata
|
|
2340
|
+
);
|
|
2341
|
+
case "handler" /* Handler */:
|
|
2342
|
+
this.logger.error("Not implemented yet");
|
|
2343
|
+
throw new import_common4.NaviosException("Not implemented yet");
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
provideHandlerForConfig(controller, executionContext, endpointMetadata) {
|
|
2347
|
+
return async (request, reply) => {
|
|
2348
|
+
getServiceLocator().registerInstance(Request, request);
|
|
2349
|
+
getServiceLocator().registerInstance(Reply, reply);
|
|
2350
|
+
getServiceLocator().registerInstance(
|
|
2351
|
+
ExecutionContextToken,
|
|
2352
|
+
executionContext
|
|
2353
|
+
);
|
|
2354
|
+
executionContext.provideRequest(request);
|
|
2355
|
+
executionContext.provideReply(reply);
|
|
2356
|
+
const controllerInstance = await inject(controller);
|
|
2357
|
+
try {
|
|
2358
|
+
const { query, params, body } = request;
|
|
2359
|
+
const argument = {};
|
|
2360
|
+
if (query && Object.keys(query).length > 0) {
|
|
2361
|
+
argument.params = query;
|
|
2362
|
+
}
|
|
2363
|
+
if (params && Object.keys(params).length > 0) {
|
|
2364
|
+
argument.urlParams = params;
|
|
2365
|
+
}
|
|
2366
|
+
if (body) {
|
|
2367
|
+
argument.data = body;
|
|
2368
|
+
}
|
|
2369
|
+
const result = await controllerInstance[endpointMetadata.classMethod](argument);
|
|
2370
|
+
reply.status(endpointMetadata.successStatusCode).headers(endpointMetadata.headers).send(result);
|
|
2371
|
+
} finally {
|
|
2372
|
+
getServiceLocator().removeInstance(Request);
|
|
2373
|
+
getServiceLocator().removeInstance(Reply);
|
|
2374
|
+
getServiceLocator().removeInstance(ExecutionContextToken);
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2283
2378
|
};
|
|
2284
2379
|
_init6 = __decoratorStart(null);
|
|
2285
2380
|
_ControllerAdapterService = __decorateElement(_init6, 0, "ControllerAdapterService", _ControllerAdapterService_decorators, _ControllerAdapterService);
|
|
@@ -2433,6 +2528,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2433
2528
|
}
|
|
2434
2529
|
await this.moduleLoader.loadModules(this.appModule);
|
|
2435
2530
|
this.server = await this.getFastifyInstance(this.options);
|
|
2531
|
+
this.configureFastifyInstance(this.server);
|
|
2436
2532
|
getServiceLocator().registerInstance(Application, this.server);
|
|
2437
2533
|
this.server.setValidatorCompiler(import_fastify_type_provider_zod.validatorCompiler);
|
|
2438
2534
|
this.server.setSerializerCompiler(import_fastify_type_provider_zod.serializerCompiler);
|
|
@@ -2440,6 +2536,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2440
2536
|
await this.server.register(import_cors.default, this.corsOptions);
|
|
2441
2537
|
}
|
|
2442
2538
|
await this.initModules();
|
|
2539
|
+
await this.server.ready();
|
|
2443
2540
|
this.logger.debug("Navios application initialized");
|
|
2444
2541
|
}
|
|
2445
2542
|
async getFastifyInstance(rawOptions) {
|
|
@@ -2469,6 +2566,35 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2469
2566
|
});
|
|
2470
2567
|
}
|
|
2471
2568
|
}
|
|
2569
|
+
configureFastifyInstance(fastifyInstance) {
|
|
2570
|
+
fastifyInstance.setErrorHandler((error, request, reply) => {
|
|
2571
|
+
if (error instanceof HttpException) {
|
|
2572
|
+
return reply.status(error.statusCode).send(error.response);
|
|
2573
|
+
} else {
|
|
2574
|
+
const statusCode = error.statusCode || 500;
|
|
2575
|
+
const message = error.message || "Internal Server Error";
|
|
2576
|
+
const response = {
|
|
2577
|
+
statusCode,
|
|
2578
|
+
message,
|
|
2579
|
+
error: error.name || "InternalServerError"
|
|
2580
|
+
};
|
|
2581
|
+
this.logger.error(
|
|
2582
|
+
`Error occurred: ${error.message} on ${request.url}`,
|
|
2583
|
+
error
|
|
2584
|
+
);
|
|
2585
|
+
return reply.status(statusCode).send(response);
|
|
2586
|
+
}
|
|
2587
|
+
});
|
|
2588
|
+
fastifyInstance.setNotFoundHandler((req, reply) => {
|
|
2589
|
+
const response = {
|
|
2590
|
+
statusCode: 404,
|
|
2591
|
+
message: "Not Found",
|
|
2592
|
+
error: "NotFound"
|
|
2593
|
+
};
|
|
2594
|
+
this.logger.error(`Route not found: ${req.url}`);
|
|
2595
|
+
return reply.status(404).send(response);
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2472
2598
|
async initModules() {
|
|
2473
2599
|
const modules = this.moduleLoader.getAllModules();
|
|
2474
2600
|
const promises = [];
|
|
@@ -2512,7 +2638,8 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2512
2638
|
if (!this.server) {
|
|
2513
2639
|
throw new Error("Server is not initialized. Call init() first.");
|
|
2514
2640
|
}
|
|
2515
|
-
await this.server.listen(options);
|
|
2641
|
+
const res = await this.server.listen(options);
|
|
2642
|
+
this.logger.debug(`Navios is listening on ${res}`);
|
|
2516
2643
|
}
|
|
2517
2644
|
};
|
|
2518
2645
|
_init8 = __decoratorStart(null);
|
|
@@ -2543,9 +2670,9 @@ var NaviosFactory = class {
|
|
|
2543
2670
|
Application,
|
|
2544
2671
|
AttributeFactory,
|
|
2545
2672
|
BadRequestException,
|
|
2673
|
+
BoundInjectionToken,
|
|
2546
2674
|
ConfigProvider,
|
|
2547
2675
|
ConfigProviderFactory,
|
|
2548
|
-
ConfigProviderInjectionToken,
|
|
2549
2676
|
ConfigProviderOptions,
|
|
2550
2677
|
ConfigServiceInstance,
|
|
2551
2678
|
ConflictException,
|
|
@@ -2555,14 +2682,19 @@ var NaviosFactory = class {
|
|
|
2555
2682
|
ControllerMetadataKey,
|
|
2556
2683
|
Endpoint,
|
|
2557
2684
|
EndpointMetadataKey,
|
|
2685
|
+
EndpointType,
|
|
2558
2686
|
ErrorsEnum,
|
|
2559
2687
|
EventEmitter,
|
|
2560
2688
|
ExecutionContext,
|
|
2561
2689
|
ExecutionContextInjectionToken,
|
|
2562
2690
|
ExecutionContextToken,
|
|
2691
|
+
FactoryInjectionToken,
|
|
2563
2692
|
FactoryNotFound,
|
|
2693
|
+
FactoryTokenNotResolved,
|
|
2564
2694
|
ForbiddenException,
|
|
2565
2695
|
GuardRunnerService,
|
|
2696
|
+
Header,
|
|
2697
|
+
HttpCode,
|
|
2566
2698
|
HttpException,
|
|
2567
2699
|
Injectable,
|
|
2568
2700
|
InjectableScope,
|
|
@@ -2624,10 +2756,11 @@ var NaviosFactory = class {
|
|
|
2624
2756
|
isString,
|
|
2625
2757
|
isSymbol,
|
|
2626
2758
|
isUndefined,
|
|
2627
|
-
makeConfigToken,
|
|
2628
2759
|
normalizePath,
|
|
2629
2760
|
override,
|
|
2761
|
+
provideConfig,
|
|
2630
2762
|
provideServiceLocator,
|
|
2763
|
+
resolveService,
|
|
2631
2764
|
setPromiseCollector,
|
|
2632
2765
|
stripEndSlash,
|
|
2633
2766
|
syncInject,
|