@navios/core 0.1.5 → 0.1.7
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/_tsup-dts-rollup.d.mts +1485 -0
- package/dist/_tsup-dts-rollup.d.ts +1485 -0
- package/dist/index.d.mts +134 -940
- package/dist/index.d.ts +134 -940
- package/dist/index.js +19 -1
- package/dist/index.mjs +19 -1
- package/package.json +4 -4
- package/src/__tests__/controller.spec.mts +2 -2
- package/src/decorators/endpoint.decorator.mts +1 -1
- package/src/navios.application.mts +17 -0
- package/src/services/module-loader.service.mts +5 -0
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2438,6 +2438,11 @@ var _ModuleLoaderService = class _ModuleLoaderService {
|
|
|
2438
2438
|
getAllModules() {
|
|
2439
2439
|
return this.modulesMetadata;
|
|
2440
2440
|
}
|
|
2441
|
+
dispose() {
|
|
2442
|
+
this.modulesMetadata.clear();
|
|
2443
|
+
this.loadedModules.clear();
|
|
2444
|
+
this.initialized = false;
|
|
2445
|
+
}
|
|
2441
2446
|
};
|
|
2442
2447
|
_init7 = __decoratorStart(null);
|
|
2443
2448
|
_ModuleLoaderService = __decorateElement(_init7, 0, "ModuleLoaderService", _ModuleLoaderService_decorators, _ModuleLoaderService);
|
|
@@ -2518,6 +2523,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2518
2523
|
globalPrefix = null;
|
|
2519
2524
|
appModule = null;
|
|
2520
2525
|
options = {};
|
|
2526
|
+
isInitialized = false;
|
|
2521
2527
|
setup(appModule, options = {}) {
|
|
2522
2528
|
this.appModule = appModule;
|
|
2523
2529
|
this.options = options;
|
|
@@ -2537,6 +2543,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2537
2543
|
}
|
|
2538
2544
|
await this.initModules();
|
|
2539
2545
|
await this.server.ready();
|
|
2546
|
+
this.isInitialized = true;
|
|
2540
2547
|
this.logger.debug("Navios application initialized");
|
|
2541
2548
|
}
|
|
2542
2549
|
async getFastifyInstance(rawOptions) {
|
|
@@ -2641,6 +2648,18 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2641
2648
|
const res = await this.server.listen(options);
|
|
2642
2649
|
this.logger.debug(`Navios is listening on ${res}`);
|
|
2643
2650
|
}
|
|
2651
|
+
async dispose() {
|
|
2652
|
+
if (this.server) {
|
|
2653
|
+
await this.server.close();
|
|
2654
|
+
this.server = null;
|
|
2655
|
+
}
|
|
2656
|
+
if (this.moduleLoader) {
|
|
2657
|
+
this.moduleLoader.dispose();
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
async close() {
|
|
2661
|
+
await this.dispose();
|
|
2662
|
+
}
|
|
2644
2663
|
};
|
|
2645
2664
|
_init8 = __decoratorStart(null);
|
|
2646
2665
|
_NaviosApplication = __decorateElement(_init8, 0, "NaviosApplication", _NaviosApplication_decorators, _NaviosApplication);
|
|
@@ -2766,4 +2785,3 @@ var NaviosFactory = class {
|
|
|
2766
2785
|
syncInject,
|
|
2767
2786
|
yellow
|
|
2768
2787
|
});
|
|
2769
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -2309,6 +2309,11 @@ var _ModuleLoaderService = class _ModuleLoaderService {
|
|
|
2309
2309
|
getAllModules() {
|
|
2310
2310
|
return this.modulesMetadata;
|
|
2311
2311
|
}
|
|
2312
|
+
dispose() {
|
|
2313
|
+
this.modulesMetadata.clear();
|
|
2314
|
+
this.loadedModules.clear();
|
|
2315
|
+
this.initialized = false;
|
|
2316
|
+
}
|
|
2312
2317
|
};
|
|
2313
2318
|
_init7 = __decoratorStart(null);
|
|
2314
2319
|
_ModuleLoaderService = __decorateElement(_init7, 0, "ModuleLoaderService", _ModuleLoaderService_decorators, _ModuleLoaderService);
|
|
@@ -2392,6 +2397,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2392
2397
|
globalPrefix = null;
|
|
2393
2398
|
appModule = null;
|
|
2394
2399
|
options = {};
|
|
2400
|
+
isInitialized = false;
|
|
2395
2401
|
setup(appModule, options = {}) {
|
|
2396
2402
|
this.appModule = appModule;
|
|
2397
2403
|
this.options = options;
|
|
@@ -2411,6 +2417,7 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2411
2417
|
}
|
|
2412
2418
|
await this.initModules();
|
|
2413
2419
|
await this.server.ready();
|
|
2420
|
+
this.isInitialized = true;
|
|
2414
2421
|
this.logger.debug("Navios application initialized");
|
|
2415
2422
|
}
|
|
2416
2423
|
async getFastifyInstance(rawOptions) {
|
|
@@ -2515,6 +2522,18 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2515
2522
|
const res = await this.server.listen(options);
|
|
2516
2523
|
this.logger.debug(`Navios is listening on ${res}`);
|
|
2517
2524
|
}
|
|
2525
|
+
async dispose() {
|
|
2526
|
+
if (this.server) {
|
|
2527
|
+
await this.server.close();
|
|
2528
|
+
this.server = null;
|
|
2529
|
+
}
|
|
2530
|
+
if (this.moduleLoader) {
|
|
2531
|
+
this.moduleLoader.dispose();
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
async close() {
|
|
2535
|
+
await this.dispose();
|
|
2536
|
+
}
|
|
2518
2537
|
};
|
|
2519
2538
|
_init8 = __decoratorStart(null);
|
|
2520
2539
|
_NaviosApplication = __decorateElement(_init8, 0, "NaviosApplication", _NaviosApplication_decorators, _NaviosApplication);
|
|
@@ -2639,4 +2658,3 @@ export {
|
|
|
2639
2658
|
syncInject,
|
|
2640
2659
|
yellow
|
|
2641
2660
|
};
|
|
2642
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Oleksandr Hanzha",
|
|
6
6
|
"email": "alex@granted.name"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"module": "./dist/index.mjs",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@navios/common": "^0.1.
|
|
18
|
+
"@navios/common": "^0.1.1",
|
|
19
19
|
"zod": "^3.23.8"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@navios/common": "^0.1.
|
|
35
|
+
"@navios/common": "^0.1.1",
|
|
36
36
|
"tsx": "^4.19.4",
|
|
37
37
|
"typescript": "^5.8.3",
|
|
38
|
-
"zod": "^3.24.
|
|
38
|
+
"zod": "^3.24.4"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@fastify/cors": "^11.0.1",
|
|
@@ -36,14 +36,14 @@ describe('Controller decorator', () => {
|
|
|
36
36
|
@Controller()
|
|
37
37
|
class Test {
|
|
38
38
|
@Endpoint(endpoint)
|
|
39
|
-
getBar(params: EndpointParams<typeof endpoint>) {
|
|
39
|
+
async getBar(params: EndpointParams<typeof endpoint>) {
|
|
40
40
|
return {
|
|
41
41
|
foo: 'bar',
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@Endpoint(endpoint2)
|
|
46
|
-
postBar(params: EndpointParams<typeof endpoint2>) {
|
|
46
|
+
async postBar(params: EndpointParams<typeof endpoint2>) {
|
|
47
47
|
return {
|
|
48
48
|
foo: params.data.test,
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ export function Endpoint<
|
|
|
53
53
|
: RequestSchema extends ZodType
|
|
54
54
|
? EndpointFunctionArgs<Url, undefined, RequestSchema>
|
|
55
55
|
: EndpointFunctionArgs<Url, undefined, undefined>,
|
|
56
|
-
) => z.input<ResponseSchema
|
|
56
|
+
) => Promise<z.input<ResponseSchema>>,
|
|
57
57
|
context: ClassMethodDecoratorContext,
|
|
58
58
|
) => {
|
|
59
59
|
if (typeof target !== 'function') {
|
|
@@ -55,6 +55,8 @@ export class NaviosApplication {
|
|
|
55
55
|
private appModule: ClassTypeWithInstance<NaviosModule> | null = null
|
|
56
56
|
private options: NaviosApplicationOptions = {}
|
|
57
57
|
|
|
58
|
+
isInitialized = false
|
|
59
|
+
|
|
58
60
|
setup(
|
|
59
61
|
appModule: ClassTypeWithInstance<NaviosModule>,
|
|
60
62
|
options: NaviosApplicationOptions = {},
|
|
@@ -82,6 +84,7 @@ export class NaviosApplication {
|
|
|
82
84
|
await this.initModules()
|
|
83
85
|
await this.server.ready()
|
|
84
86
|
|
|
87
|
+
this.isInitialized = true
|
|
85
88
|
this.logger.debug('Navios application initialized')
|
|
86
89
|
}
|
|
87
90
|
|
|
@@ -198,4 +201,18 @@ export class NaviosApplication {
|
|
|
198
201
|
const res = await this.server.listen(options)
|
|
199
202
|
this.logger.debug(`Navios is listening on ${res}`)
|
|
200
203
|
}
|
|
204
|
+
|
|
205
|
+
async dispose() {
|
|
206
|
+
if (this.server) {
|
|
207
|
+
await this.server.close()
|
|
208
|
+
this.server = null
|
|
209
|
+
}
|
|
210
|
+
if (this.moduleLoader) {
|
|
211
|
+
this.moduleLoader.dispose()
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async close() {
|
|
216
|
+
await this.dispose()
|
|
217
|
+
}
|
|
201
218
|
}
|