@navios/core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.md +18 -1
- package/docs/README.md +1 -0
- package/docs/legacy-compat.md +320 -0
- package/docs/testing.md +140 -17
- package/lib/index-BFwNx9WQ.d.cts +1951 -0
- package/lib/index-BFwNx9WQ.d.cts.map +1 -0
- package/lib/index-D657ijFO.d.mts +1951 -0
- package/lib/index-D657ijFO.d.mts.map +1 -0
- package/lib/index.cjs +157 -0
- package/lib/index.d.cts +3 -0
- package/lib/index.d.mts +3 -190
- package/lib/index.mjs +4 -1459
- package/lib/legacy-compat/index.cjs +315 -0
- package/lib/legacy-compat/index.cjs.map +1 -0
- package/lib/legacy-compat/index.d.cts +219 -0
- package/lib/legacy-compat/index.d.cts.map +1 -0
- package/lib/legacy-compat/index.d.mts +219 -0
- package/lib/legacy-compat/index.d.mts.map +1 -0
- package/lib/legacy-compat/index.mjs +308 -0
- package/lib/legacy-compat/index.mjs.map +1 -0
- package/lib/src-Cb1aTjl0.cjs +5710 -0
- package/lib/src-Cb1aTjl0.cjs.map +1 -0
- package/lib/src-DzPY5s6d.mjs +5353 -0
- package/lib/src-DzPY5s6d.mjs.map +1 -0
- package/lib/testing/index.cjs +106 -0
- package/lib/testing/index.cjs.map +1 -0
- package/lib/testing/index.d.cts +156 -0
- package/lib/testing/index.d.cts.map +1 -0
- package/lib/testing/index.d.mts +156 -0
- package/lib/testing/index.d.mts.map +1 -0
- package/lib/testing/index.mjs +100 -0
- package/lib/testing/index.mjs.map +1 -0
- package/lib/use-guards.decorator-DdvUhB03.cjs +622 -0
- package/lib/use-guards.decorator-DdvUhB03.cjs.map +1 -0
- package/lib/use-guards.decorator-kZ3lNK8v.mjs +454 -0
- package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +1 -0
- package/package.json +24 -4
- package/project.json +2 -2
- package/src/attribute.factory.d.mts +175 -0
- package/src/attribute.factory.d.mts.map +1 -0
- package/src/attribute.factory.mts +154 -0
- package/src/config/config-service.interface.d.mts +39 -0
- package/src/config/config-service.interface.d.mts.map +1 -0
- package/src/config/config-service.interface.mts +31 -0
- package/src/config/config.provider.d.mts +46 -0
- package/src/config/config.provider.d.mts.map +1 -0
- package/src/config/config.provider.mts +36 -0
- package/src/config/config.service.d.mts +108 -0
- package/src/config/config.service.d.mts.map +1 -0
- package/src/config/config.service.mts +94 -4
- package/src/config/index.d.mts +6 -0
- package/src/config/index.d.mts.map +1 -0
- package/src/config/types.d.mts +13 -0
- package/src/config/types.d.mts.map +1 -0
- package/src/config/utils/helpers.d.mts +3 -0
- package/src/config/utils/helpers.d.mts.map +1 -0
- package/src/config/utils/index.d.mts +2 -0
- package/src/config/utils/index.d.mts.map +1 -0
- package/src/decorators/controller.decorator.d.mts +33 -0
- package/src/decorators/controller.decorator.d.mts.map +1 -0
- package/src/decorators/controller.decorator.mts +28 -0
- package/src/decorators/endpoint.decorator.d.mts +89 -0
- package/src/decorators/endpoint.decorator.d.mts.map +1 -0
- package/src/decorators/endpoint.decorator.mts +76 -0
- package/src/decorators/header.decorator.d.mts +22 -0
- package/src/decorators/header.decorator.d.mts.map +1 -0
- package/src/decorators/header.decorator.mts +19 -0
- package/src/decorators/http-code.decorator.d.mts +22 -0
- package/src/decorators/http-code.decorator.d.mts.map +1 -0
- package/src/decorators/http-code.decorator.mts +20 -0
- package/src/decorators/index.d.mts +9 -0
- package/src/decorators/index.d.mts.map +1 -0
- package/src/decorators/module.decorator.d.mts +42 -0
- package/src/decorators/module.decorator.d.mts.map +1 -0
- package/src/decorators/module.decorator.mts +34 -0
- package/src/decorators/multipart.decorator.d.mts +54 -0
- package/src/decorators/multipart.decorator.d.mts.map +1 -0
- package/src/decorators/multipart.decorator.mts +41 -0
- package/src/decorators/stream.decorator.d.mts +42 -0
- package/src/decorators/stream.decorator.d.mts.map +1 -0
- package/src/decorators/stream.decorator.mts +33 -0
- package/src/decorators/use-guards.decorator.d.mts +33 -0
- package/src/decorators/use-guards.decorator.d.mts.map +1 -0
- package/src/decorators/use-guards.decorator.mts +29 -0
- package/src/exceptions/bad-request.exception.d.mts +26 -0
- package/src/exceptions/bad-request.exception.d.mts.map +1 -0
- package/src/exceptions/bad-request.exception.mts +21 -0
- package/src/exceptions/conflict.exception.d.mts +29 -0
- package/src/exceptions/conflict.exception.d.mts.map +1 -0
- package/src/exceptions/conflict.exception.mts +24 -0
- package/src/exceptions/forbidden.exception.d.mts +28 -0
- package/src/exceptions/forbidden.exception.d.mts.map +1 -0
- package/src/exceptions/forbidden.exception.mts +23 -0
- package/src/exceptions/http.exception.d.mts +33 -0
- package/src/exceptions/http.exception.d.mts.map +1 -0
- package/src/exceptions/http.exception.mts +26 -0
- package/src/exceptions/index.d.mts +8 -0
- package/src/exceptions/index.d.mts.map +1 -0
- package/src/exceptions/internal-server-error.exception.d.mts +31 -0
- package/src/exceptions/internal-server-error.exception.d.mts.map +1 -0
- package/src/exceptions/internal-server-error.exception.mts +26 -0
- package/src/exceptions/not-found.exception.d.mts +30 -0
- package/src/exceptions/not-found.exception.d.mts.map +1 -0
- package/src/exceptions/not-found.exception.mts +23 -0
- package/src/exceptions/unauthorized.exception.d.mts +28 -0
- package/src/exceptions/unauthorized.exception.d.mts.map +1 -0
- package/src/exceptions/unauthorized.exception.mts +23 -0
- package/src/factories/endpoint-adapter.factory.d.mts +6 -0
- package/src/factories/endpoint-adapter.factory.d.mts.map +1 -0
- package/src/factories/http-adapter.factory.d.mts +6 -0
- package/src/factories/http-adapter.factory.d.mts.map +1 -0
- package/src/factories/index.d.mts +8 -0
- package/src/factories/index.d.mts.map +1 -0
- package/src/factories/multipart-adapter.factory.d.mts +6 -0
- package/src/factories/multipart-adapter.factory.d.mts.map +1 -0
- package/src/factories/reply.factory.d.mts +6 -0
- package/src/factories/reply.factory.d.mts.map +1 -0
- package/src/factories/request.factory.d.mts +6 -0
- package/src/factories/request.factory.d.mts.map +1 -0
- package/src/factories/stream-adapter.factory.d.mts +6 -0
- package/src/factories/stream-adapter.factory.d.mts.map +1 -0
- package/src/factories/xml-stream-adapter.factory.d.mts +6 -0
- package/src/factories/xml-stream-adapter.factory.d.mts.map +1 -0
- package/src/index.d.mts +15 -0
- package/src/index.d.mts.map +1 -0
- package/src/index.mts +1 -0
- package/src/interfaces/abstract-execution-context.inteface.d.mts +44 -0
- package/src/interfaces/abstract-execution-context.inteface.d.mts.map +1 -0
- package/src/interfaces/abstract-execution-context.inteface.mts +35 -0
- package/src/interfaces/abstract-http-adapter.interface.d.mts +15 -0
- package/src/interfaces/abstract-http-adapter.interface.d.mts.map +1 -0
- package/src/interfaces/abstract-http-cors-options.interface.d.mts +58 -0
- package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +1 -0
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +7 -0
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +1 -0
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +2 -2
- package/src/interfaces/abstract-http-listen-options.interface.d.mts +5 -0
- package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +1 -0
- package/src/interfaces/can-activate.d.mts +36 -0
- package/src/interfaces/can-activate.d.mts.map +1 -0
- package/src/interfaces/can-activate.mts +31 -0
- package/src/interfaces/http-header.d.mts +10 -0
- package/src/interfaces/http-header.d.mts.map +1 -0
- package/src/interfaces/index.d.mts +9 -0
- package/src/interfaces/index.d.mts.map +1 -0
- package/src/interfaces/navios-module.d.mts +29 -0
- package/src/interfaces/navios-module.d.mts.map +1 -0
- package/src/interfaces/navios-module.mts +25 -0
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +420 -0
- package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
- package/src/legacy-compat/context-compat.d.mts +19 -0
- package/src/legacy-compat/context-compat.d.mts.map +1 -0
- package/src/legacy-compat/context-compat.mts +93 -0
- package/src/legacy-compat/decorators/controller.decorator.d.mts +21 -0
- package/src/legacy-compat/decorators/controller.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/controller.decorator.mts +31 -0
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts +33 -0
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/endpoint.decorator.mts +99 -0
- package/src/legacy-compat/decorators/header.decorator.d.mts +24 -0
- package/src/legacy-compat/decorators/header.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/header.decorator.mts +42 -0
- package/src/legacy-compat/decorators/http-code.decorator.d.mts +22 -0
- package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/http-code.decorator.mts +38 -0
- package/src/legacy-compat/decorators/index.d.mts +9 -0
- package/src/legacy-compat/decorators/index.d.mts.map +1 -0
- package/src/legacy-compat/decorators/index.mts +9 -0
- package/src/legacy-compat/decorators/module.decorator.d.mts +22 -0
- package/src/legacy-compat/decorators/module.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/module.decorator.mts +37 -0
- package/src/legacy-compat/decorators/multipart.decorator.d.mts +34 -0
- package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/multipart.decorator.mts +93 -0
- package/src/legacy-compat/decorators/stream.decorator.d.mts +34 -0
- package/src/legacy-compat/decorators/stream.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/stream.decorator.mts +76 -0
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts +29 -0
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +1 -0
- package/src/legacy-compat/decorators/use-guards.decorator.mts +80 -0
- package/src/legacy-compat/index.d.mts +19 -0
- package/src/legacy-compat/index.d.mts.map +1 -0
- package/src/legacy-compat/index.mts +40 -0
- package/src/logger/console-logger.service.d.mts +196 -0
- package/src/logger/console-logger.service.d.mts.map +1 -0
- package/src/logger/console-logger.service.mts +15 -2
- package/src/logger/index.d.mts +7 -0
- package/src/logger/index.d.mts.map +1 -0
- package/src/logger/log-levels.d.mts +14 -0
- package/src/logger/log-levels.d.mts.map +1 -0
- package/src/logger/log-levels.mts +9 -0
- package/src/logger/logger-service.interface.d.mts +36 -0
- package/src/logger/logger-service.interface.d.mts.map +1 -0
- package/src/logger/logger.service.d.mts +57 -0
- package/src/logger/logger.service.d.mts.map +1 -0
- package/src/logger/logger.service.mts +19 -0
- package/src/logger/logger.tokens.d.mts +36 -0
- package/src/logger/logger.tokens.d.mts.map +1 -0
- package/src/logger/logger.tokens.mts +23 -0
- package/src/logger/utils/cli-colors.util.d.mts +10 -0
- package/src/logger/utils/cli-colors.util.d.mts.map +1 -0
- package/src/logger/utils/filter-log-levelts.util.d.mts +6 -0
- package/src/logger/utils/filter-log-levelts.util.d.mts.map +1 -0
- package/src/logger/utils/index.d.mts +6 -0
- package/src/logger/utils/index.d.mts.map +1 -0
- package/src/logger/utils/is-log-level-enabled.d.mts +8 -0
- package/src/logger/utils/is-log-level-enabled.d.mts.map +1 -0
- package/src/logger/utils/is-log-level.util.d.mts +6 -0
- package/src/logger/utils/is-log-level.util.d.mts.map +1 -0
- package/src/logger/utils/shared.utils.d.mts +14 -0
- package/src/logger/utils/shared.utils.d.mts.map +1 -0
- package/src/metadata/controller.metadata.d.mts +13 -0
- package/src/metadata/controller.metadata.d.mts.map +1 -0
- package/src/metadata/handler.metadata.d.mts +18 -0
- package/src/metadata/handler.metadata.d.mts.map +1 -0
- package/src/metadata/index.d.mts +4 -0
- package/src/metadata/index.d.mts.map +1 -0
- package/src/metadata/module.metadata.d.mts +13 -0
- package/src/metadata/module.metadata.d.mts.map +1 -0
- package/src/navios.application.d.mts +210 -0
- package/src/navios.application.d.mts.map +1 -0
- package/src/navios.application.mts +176 -2
- package/src/navios.environment.d.mts +11 -0
- package/src/navios.environment.d.mts.map +1 -0
- package/src/navios.factory.d.mts +68 -0
- package/src/navios.factory.d.mts.map +1 -0
- package/src/navios.factory.mts +59 -1
- package/src/services/guard-runner.service.d.mts +10 -0
- package/src/services/guard-runner.service.d.mts.map +1 -0
- package/src/services/guard-runner.service.mts +12 -11
- package/src/services/index.d.mts +3 -0
- package/src/services/index.d.mts.map +1 -0
- package/src/services/module-loader.service.d.mts +17 -0
- package/src/services/module-loader.service.d.mts.map +1 -0
- package/src/services/module-loader.service.mts +16 -11
- package/src/stores/index.d.mts +2 -0
- package/src/stores/index.d.mts.map +1 -0
- package/src/stores/index.mts +1 -0
- package/src/stores/request-id.store.d.mts +37 -0
- package/src/stores/request-id.store.d.mts.map +1 -0
- package/src/stores/request-id.store.mts +43 -0
- package/src/testing/index.mts +2 -0
- package/src/testing/testing-module.mts +231 -0
- package/src/tokens/endpoint-adapter.token.d.mts +4 -0
- package/src/tokens/endpoint-adapter.token.d.mts.map +1 -0
- package/src/tokens/execution-context.token.d.mts +5 -0
- package/src/tokens/execution-context.token.d.mts.map +1 -0
- package/src/tokens/http-adapter.token.d.mts +4 -0
- package/src/tokens/http-adapter.token.d.mts.map +1 -0
- package/src/tokens/index.d.mts +9 -0
- package/src/tokens/index.d.mts.map +1 -0
- package/src/tokens/multipart-adapter.token.d.mts +4 -0
- package/src/tokens/multipart-adapter.token.d.mts.map +1 -0
- package/src/tokens/reply.token.d.mts +3 -0
- package/src/tokens/reply.token.d.mts.map +1 -0
- package/src/tokens/request.token.d.mts +3 -0
- package/src/tokens/request.token.d.mts.map +1 -0
- package/src/tokens/stream-adapter.token.d.mts +4 -0
- package/src/tokens/stream-adapter.token.d.mts.map +1 -0
- package/src/tokens/xml-stream-adapter.token.d.mts +4 -0
- package/src/tokens/xml-stream-adapter.token.d.mts.map +1 -0
- package/tsconfig.lib.json +1 -1
- package/tsconfig.spec.json +3 -0
- package/tsdown.config.mts +35 -0
- package/vitest.config.mts +6 -0
- package/lib/_tsup-dts-rollup.d.mts +0 -1365
- package/lib/_tsup-dts-rollup.d.ts +0 -1365
- package/lib/index.d.ts +0 -190
- package/lib/index.js +0 -1540
- package/lib/index.js.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/tsup.config.mts +0 -13
|
@@ -4,10 +4,45 @@ import type {
|
|
|
4
4
|
ModuleMetadata,
|
|
5
5
|
} from '../metadata/index.mjs'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Interface providing access to the execution context during request handling.
|
|
9
|
+
*
|
|
10
|
+
* The execution context provides access to metadata and request/reply objects
|
|
11
|
+
* for the current request. It is available in guards and can be injected into
|
|
12
|
+
* services if needed.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @Injectable()
|
|
17
|
+
* export class AuthGuard implements CanActivate {
|
|
18
|
+
* async canActivate(context: AbstractExecutionContext): Promise<boolean> {
|
|
19
|
+
* const request = context.getRequest()
|
|
20
|
+
* const handler = context.getHandler()
|
|
21
|
+
* // Access request and handler metadata
|
|
22
|
+
* return true
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
7
27
|
export interface AbstractExecutionContext {
|
|
28
|
+
/**
|
|
29
|
+
* Gets the metadata for the module containing the current endpoint.
|
|
30
|
+
*/
|
|
8
31
|
getModule(): ModuleMetadata
|
|
32
|
+
/**
|
|
33
|
+
* Gets the metadata for the controller containing the current endpoint.
|
|
34
|
+
*/
|
|
9
35
|
getController(): ControllerMetadata
|
|
36
|
+
/**
|
|
37
|
+
* Gets the metadata for the current endpoint handler.
|
|
38
|
+
*/
|
|
10
39
|
getHandler(): HandlerMetadata
|
|
40
|
+
/**
|
|
41
|
+
* Gets the HTTP request object (adapter-specific).
|
|
42
|
+
*/
|
|
11
43
|
getRequest(): any
|
|
44
|
+
/**
|
|
45
|
+
* Gets the HTTP reply object (adapter-specific).
|
|
46
|
+
*/
|
|
12
47
|
getReply(): any
|
|
13
48
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModuleMetadata } from '../metadata/index.mjs';
|
|
2
|
+
import type { AbstractHttpCorsOptions } from './abstract-http-cors-options.interface.mjs';
|
|
3
|
+
import type { AbstractHttpListenOptions } from './abstract-http-listen-options.interface.mjs';
|
|
4
|
+
export interface AbstractHttpAdapterInterface<ServerInstance, CorsOptions = AbstractHttpCorsOptions, Options = {}, MultipartOptions = {}> {
|
|
5
|
+
setupHttpServer(options: Options): Promise<void>;
|
|
6
|
+
onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>;
|
|
7
|
+
ready(): Promise<void>;
|
|
8
|
+
getServer(): ServerInstance;
|
|
9
|
+
setGlobalPrefix(prefix: string): void;
|
|
10
|
+
enableCors(options: CorsOptions): void;
|
|
11
|
+
enableMultipart(options: MultipartOptions): void;
|
|
12
|
+
listen(options: AbstractHttpListenOptions): Promise<string>;
|
|
13
|
+
dispose(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=abstract-http-adapter.interface.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-http-adapter.interface.d.mts","sourceRoot":"","sources":["abstract-http-adapter.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAA;AAE7F,MAAM,WAAW,4BAA4B,CAC3C,cAAc,EACd,WAAW,GAAG,uBAAuB,EACrC,OAAO,GAAG,EAAE,EACZ,gBAAgB,GAAG,EAAE;IAErB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,SAAS,IAAI,cAAc,CAAA;IAC3B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IACtC,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAChD,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { LogLevel } from '../logger/index.mjs';
|
|
2
|
+
interface ArrayOfValueOrArray<T> extends Array<ValueOrArray<T>> {
|
|
3
|
+
}
|
|
4
|
+
type OriginType = string | boolean | RegExp;
|
|
5
|
+
type ValueOrArray<T> = T | ArrayOfValueOrArray<T>;
|
|
6
|
+
export interface AbstractHttpCorsOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Configures the Access-Control-Allow-Origin CORS header.
|
|
9
|
+
*/
|
|
10
|
+
origin?: ValueOrArray<OriginType>;
|
|
11
|
+
/**
|
|
12
|
+
* Configures the Access-Control-Allow-Credentials CORS header.
|
|
13
|
+
* Set to true to pass the header, otherwise it is omitted.
|
|
14
|
+
*/
|
|
15
|
+
credentials?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Configures the Access-Control-Expose-Headers CORS header.
|
|
18
|
+
* Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range')
|
|
19
|
+
* or an array (ex: ['Content-Range', 'X-Content-Range']).
|
|
20
|
+
* If not specified, no custom headers are exposed.
|
|
21
|
+
*/
|
|
22
|
+
exposedHeaders?: string | string[];
|
|
23
|
+
/**
|
|
24
|
+
* Configures the Access-Control-Allow-Headers CORS header.
|
|
25
|
+
* Expects a comma-delimited string (ex: 'Content-Type,Authorization')
|
|
26
|
+
* or an array (ex: ['Content-Type', 'Authorization']). If not
|
|
27
|
+
* specified, defaults to reflecting the headers specified in the
|
|
28
|
+
* request's Access-Control-Request-Headers header.
|
|
29
|
+
*/
|
|
30
|
+
allowedHeaders?: string | string[];
|
|
31
|
+
/**
|
|
32
|
+
* Configures the Access-Control-Allow-Methods CORS header.
|
|
33
|
+
* Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']).
|
|
34
|
+
*/
|
|
35
|
+
methods?: string | string[];
|
|
36
|
+
/**
|
|
37
|
+
* Configures the Access-Control-Max-Age CORS header.
|
|
38
|
+
* Set to an integer to pass the header, otherwise it is omitted.
|
|
39
|
+
*/
|
|
40
|
+
maxAge?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Configures the Cache-Control header for CORS preflight responses.
|
|
43
|
+
* Set to an integer to pass the header as `Cache-Control: max-age=${cacheControl}`,
|
|
44
|
+
* or set to a string to pass the header as `Cache-Control: ${cacheControl}` (fully define
|
|
45
|
+
* the header value), otherwise the header is omitted.
|
|
46
|
+
*/
|
|
47
|
+
cacheControl?: number | string;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the Fastify log level specifically for the internal OPTIONS route
|
|
50
|
+
* used to handle CORS preflight requests. For example, setting this to `'silent'`
|
|
51
|
+
* will prevent these requests from being logged.
|
|
52
|
+
* Useful for reducing noise in application logs.
|
|
53
|
+
* Default: inherits Fastify's global log level.
|
|
54
|
+
*/
|
|
55
|
+
logLevel?: LogLevel;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=abstract-http-cors-options.interface.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-http-cors-options.interface.d.mts","sourceRoot":"","sources":["abstract-http-cors-options.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,UAAU,mBAAmB,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAAG;AAElE,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AAC3C,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;AAEjD,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;IACjC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAClC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAE9B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClassType, ScopedContainer } from '@navios/di';
|
|
2
|
+
import type { HandlerMetadata } from '../metadata/index.mjs';
|
|
3
|
+
export interface AbstractHttpHandlerAdapterInterface {
|
|
4
|
+
prepareArguments?: (handlerMetadata: HandlerMetadata<any>) => ((target: Record<string, any>, request: any) => Promise<void> | void)[];
|
|
5
|
+
provideHandler: (controller: ClassType, handlerMetadata: HandlerMetadata<any>) => (context: ScopedContainer, request: any, reply: any) => Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=abstract-http-handler-adapter.interface.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-http-handler-adapter.interface.d.mts","sourceRoot":"","sources":["abstract-http-handler-adapter.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,WAAW,mCAAmC;IAClD,gBAAgB,CAAC,EAAE,CACjB,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,KAClC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;IAC5E,cAAc,EAAE,CACd,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,KAClC,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAC1E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassType,
|
|
1
|
+
import type { ClassType, ScopedContainer } from '@navios/di'
|
|
2
2
|
|
|
3
3
|
import type { HandlerMetadata } from '../metadata/index.mjs'
|
|
4
4
|
|
|
@@ -9,5 +9,5 @@ export interface AbstractHttpHandlerAdapterInterface {
|
|
|
9
9
|
provideHandler: (
|
|
10
10
|
controller: ClassType,
|
|
11
11
|
handlerMetadata: HandlerMetadata<any>,
|
|
12
|
-
) => (context:
|
|
12
|
+
) => (context: ScopedContainer, request: any, reply: any) => Promise<any>
|
|
13
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-http-listen-options.interface.d.mts","sourceRoot":"","sources":["abstract-http-listen-options.interface.mts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AbstractExecutionContext } from '../interfaces/index.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Interface that guards must implement to control access to endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Guards are used for authentication, authorization, and request validation.
|
|
6
|
+
* They are executed before the endpoint handler and can prevent the request
|
|
7
|
+
* from proceeding by returning `false` or throwing an exception.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Injectable()
|
|
12
|
+
* export class AuthGuard implements CanActivate {
|
|
13
|
+
* async canActivate(context: AbstractExecutionContext): Promise<boolean> {
|
|
14
|
+
* const request = context.getRequest()
|
|
15
|
+
* const token = request.headers.authorization
|
|
16
|
+
*
|
|
17
|
+
* if (!token) {
|
|
18
|
+
* throw new UnauthorizedException('Authentication required')
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* // Validate token
|
|
22
|
+
* return true
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface CanActivate {
|
|
28
|
+
/**
|
|
29
|
+
* Determines if the current request can proceed to the endpoint handler.
|
|
30
|
+
*
|
|
31
|
+
* @param executionContext - The execution context containing request, reply, and metadata
|
|
32
|
+
* @returns `true` if the request can proceed, `false` otherwise. Can also throw an exception.
|
|
33
|
+
*/
|
|
34
|
+
canActivate(executionContext: AbstractExecutionContext): Promise<boolean> | boolean;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=can-activate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can-activate.d.mts","sourceRoot":"","sources":["can-activate.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,WAAW,CACT,gBAAgB,EAAE,wBAAwB,GACzC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;CAC9B"}
|
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import type { AbstractExecutionContext } from '../interfaces/index.mjs'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Interface that guards must implement to control access to endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Guards are used for authentication, authorization, and request validation.
|
|
7
|
+
* They are executed before the endpoint handler and can prevent the request
|
|
8
|
+
* from proceeding by returning `false` or throwing an exception.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @Injectable()
|
|
13
|
+
* export class AuthGuard implements CanActivate {
|
|
14
|
+
* async canActivate(context: AbstractExecutionContext): Promise<boolean> {
|
|
15
|
+
* const request = context.getRequest()
|
|
16
|
+
* const token = request.headers.authorization
|
|
17
|
+
*
|
|
18
|
+
* if (!token) {
|
|
19
|
+
* throw new UnauthorizedException('Authentication required')
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // Validate token
|
|
23
|
+
* return true
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
3
28
|
export interface CanActivate {
|
|
29
|
+
/**
|
|
30
|
+
* Determines if the current request can proceed to the endpoint handler.
|
|
31
|
+
*
|
|
32
|
+
* @param executionContext - The execution context containing request, reply, and metadata
|
|
33
|
+
* @returns `true` if the request can proceed, `false` otherwise. Can also throw an exception.
|
|
34
|
+
*/
|
|
4
35
|
canActivate(
|
|
5
36
|
executionContext: AbstractExecutionContext,
|
|
6
37
|
): Promise<boolean> | boolean
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OutgoingHttpHeaders } from 'http';
|
|
2
|
+
export type OmitIndexSignature<T> = {
|
|
3
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* HTTP header strings
|
|
7
|
+
* Use this type only for input values, not for output values.
|
|
8
|
+
*/
|
|
9
|
+
export type HttpHeader = keyof OmitIndexSignature<OutgoingHttpHeaders> | (string & Record<never, never>);
|
|
10
|
+
//# sourceMappingURL=http-header.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-header.d.mts","sourceRoot":"","sources":["http-header.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAE/C,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;KACjC,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,SAAS,CAAC,GAC7B,KAAK,GACL,MAAM,SAAS,CAAC,GACd,KAAK,GACL,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACf,CAAA;AAED;;;GAGG;AAEH,MAAM,MAAM,UAAU,GAClB,MAAM,kBAAkB,CAAC,mBAAmB,CAAC,GAC7C,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './abstract-execution-context.inteface.mjs';
|
|
2
|
+
export * from './abstract-http-adapter.interface.mjs';
|
|
3
|
+
export * from './abstract-http-cors-options.interface.mjs';
|
|
4
|
+
export * from './abstract-http-handler-adapter.interface.mjs';
|
|
5
|
+
export * from './abstract-http-listen-options.interface.mjs';
|
|
6
|
+
export * from './can-activate.mjs';
|
|
7
|
+
export * from './http-header.mjs';
|
|
8
|
+
export * from './navios-module.mjs';
|
|
9
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAA;AACzD,cAAc,uCAAuC,CAAA;AACrD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,8CAA8C,CAAA;AAC5D,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface that all Navios modules must implement.
|
|
3
|
+
*
|
|
4
|
+
* Modules decorated with @Module() should implement this interface to receive
|
|
5
|
+
* lifecycle hooks.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Module({
|
|
10
|
+
* controllers: [UserController],
|
|
11
|
+
* })
|
|
12
|
+
* export class AppModule implements NaviosModule {
|
|
13
|
+
* async onModuleInit() {
|
|
14
|
+
* console.log('AppModule initialized')
|
|
15
|
+
* // Perform initialization logic
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface NaviosModule {
|
|
21
|
+
/**
|
|
22
|
+
* Optional lifecycle hook called after the module is initialized.
|
|
23
|
+
*
|
|
24
|
+
* This is called after all modules are loaded and the HTTP server is set up
|
|
25
|
+
* (if an adapter is configured), but before the server starts listening.
|
|
26
|
+
*/
|
|
27
|
+
onModuleInit?: () => Promise<void> | void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=navios-module.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navios-module.d.mts","sourceRoot":"","sources":["navios-module.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAC1C"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface that all Navios modules must implement.
|
|
3
|
+
*
|
|
4
|
+
* Modules decorated with @Module() should implement this interface to receive
|
|
5
|
+
* lifecycle hooks.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Module({
|
|
10
|
+
* controllers: [UserController],
|
|
11
|
+
* })
|
|
12
|
+
* export class AppModule implements NaviosModule {
|
|
13
|
+
* async onModuleInit() {
|
|
14
|
+
* console.log('AppModule initialized')
|
|
15
|
+
* // Perform initialization logic
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
1
20
|
export interface NaviosModule {
|
|
21
|
+
/**
|
|
22
|
+
* Optional lifecycle hook called after the module is initialized.
|
|
23
|
+
*
|
|
24
|
+
* This is called after all modules are loaded and the HTTP server is set up
|
|
25
|
+
* (if an adapter is configured), but before the server starts listening.
|
|
26
|
+
*/
|
|
2
27
|
onModuleInit?: () => Promise<void> | void
|
|
3
28
|
}
|