@navios/core 0.1.1 → 0.1.3

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.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AnyZodObject, ZodOptional, z, ZodType } from 'zod';
2
2
  import { BaseEndpointConfig, EndpointFunctionArgs, HttpMethod } from '@navios/common';
3
+ import { HttpHeader } from 'fastify/types/utils.js';
3
4
  import * as fastify from 'fastify';
4
5
  import { FastifyRequest, FastifyReply, FastifyInstance, FastifyServerOptions, FastifyListenOptions } from 'fastify';
5
6
  import { InspectOptions } from 'util';
@@ -7,6 +8,152 @@ import * as http from 'http';
7
8
  import * as fastify_types_type_provider_js from 'fastify/types/type-provider.js';
8
9
  import { FastifyCorsOptions } from '@fastify/cors';
9
10
 
11
+ declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
12
+ declare function envString<DefaultValue extends string | undefined, Ensured = DefaultValue extends string ? true : false>(key: keyof NodeJS.ProcessEnv, defaultValue?: DefaultValue): Ensured extends true ? string : string | undefined;
13
+
14
+ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
15
+ /**
16
+ * @publicApi
17
+ */
18
+ type LogLevel = (typeof LOG_LEVELS)[number];
19
+
20
+ /**
21
+ * @publicApi
22
+ */
23
+ interface LoggerService {
24
+ /**
25
+ * Write a 'log' level log.
26
+ */
27
+ log(message: any, ...optionalParams: any[]): any;
28
+ /**
29
+ * Write an 'error' level log.
30
+ */
31
+ error(message: any, ...optionalParams: any[]): any;
32
+ /**
33
+ * Write a 'warn' level log.
34
+ */
35
+ warn(message: any, ...optionalParams: any[]): any;
36
+ /**
37
+ * Write a 'debug' level log.
38
+ */
39
+ debug?(message: any, ...optionalParams: any[]): any;
40
+ /**
41
+ * Write a 'verbose' level log.
42
+ */
43
+ verbose?(message: any, ...optionalParams: any[]): any;
44
+ /**
45
+ * Write a 'fatal' level log.
46
+ */
47
+ fatal?(message: any, ...optionalParams: any[]): any;
48
+ /**
49
+ * Set log levels.
50
+ * @param levels log levels
51
+ */
52
+ setLogLevels?(levels: LogLevel[]): any;
53
+ }
54
+
55
+ declare class LoggerInstance implements LoggerService {
56
+ protected context?: string | undefined;
57
+ protected options: {
58
+ timestamp?: boolean;
59
+ };
60
+ protected static staticInstanceRef?: LoggerService;
61
+ protected static logLevels?: LogLevel[];
62
+ protected localInstanceRef?: LoggerService;
63
+ constructor();
64
+ constructor(context: string);
65
+ constructor(context: string, options?: {
66
+ timestamp?: boolean;
67
+ });
68
+ get localInstance(): LoggerService;
69
+ /**
70
+ * Write an 'error' level log.
71
+ */
72
+ error(message: any, stack?: string, context?: string): void;
73
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
74
+ /**
75
+ * Write a 'log' level log.
76
+ */
77
+ log(message: any, context?: string): void;
78
+ log(message: any, ...optionalParams: [...any, string?]): void;
79
+ /**
80
+ * Write a 'warn' level log.
81
+ */
82
+ warn(message: any, context?: string): void;
83
+ warn(message: any, ...optionalParams: [...any, string?]): void;
84
+ /**
85
+ * Write a 'debug' level log.
86
+ */
87
+ debug(message: any, context?: string): void;
88
+ debug(message: any, ...optionalParams: [...any, string?]): void;
89
+ /**
90
+ * Write a 'verbose' level log.
91
+ */
92
+ verbose(message: any, context?: string): void;
93
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
94
+ /**
95
+ * Write a 'fatal' level log.
96
+ */
97
+ fatal(message: any, context?: string): void;
98
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
99
+ /**
100
+ * Write an 'error' level log.
101
+ */
102
+ static error(message: any, stackOrContext?: string): void;
103
+ static error(message: any, context?: string): void;
104
+ static error(message: any, stack?: string, context?: string): void;
105
+ static error(message: any, ...optionalParams: [...any, string?, string?]): void;
106
+ /**
107
+ * Write a 'log' level log.
108
+ */
109
+ static log(message: any, context?: string): void;
110
+ static log(message: any, ...optionalParams: [...any, string?]): void;
111
+ /**
112
+ * Write a 'warn' level log.
113
+ */
114
+ static warn(message: any, context?: string): void;
115
+ static warn(message: any, ...optionalParams: [...any, string?]): void;
116
+ /**
117
+ * Write a 'debug' level log, if the configured level allows for it.
118
+ * Prints to `stdout` with newline.
119
+ */
120
+ static debug(message: any, context?: string): void;
121
+ static debug(message: any, ...optionalParams: [...any, string?]): void;
122
+ /**
123
+ * Write a 'verbose' level log.
124
+ */
125
+ static verbose(message: any, context?: string): void;
126
+ static verbose(message: any, ...optionalParams: [...any, string?]): void;
127
+ /**
128
+ * Write a 'fatal' level log.
129
+ */
130
+ static fatal(message: any, context?: string): void;
131
+ static fatal(message: any, ...optionalParams: [...any, string?]): void;
132
+ static getTimestamp(): string;
133
+ static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
134
+ static isLevelEnabled(level: LogLevel): boolean;
135
+ private registerLocalInstanceRef;
136
+ }
137
+
138
+ /**
139
+ * Evaluates to `true` if `T` is `any`. `false` otherwise.
140
+ * (c) https://stackoverflow.com/a/68633327/5290447
141
+ */
142
+ type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
143
+ type ExcludedParts = 'services' | 'mailer' | 'aws' | 'computedTimeRates' | 'aiModelsRates';
144
+ type ExcludedKeys = 'computedTimeRates' | 'aiModelsRates' | 'aiModel';
145
+ type PathImpl<T, Key extends keyof T> = Key extends string ? Key extends ExcludedKeys ? never : IsAny<T[Key]> extends true ? never : T[Key] extends string ? never : T[Key] extends any[] ? never : T[Key] extends Record<string, any> ? Key extends ExcludedParts ? `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
146
+ type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
147
+ type Path<T> = keyof T extends string ? PathImpl2<T> extends infer P ? P extends string | keyof T ? P : keyof T : keyof T : never;
148
+ type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
149
+
150
+ interface ConfigService<Config = Record<string, unknown>> {
151
+ getConfig: () => Config;
152
+ get: <Key extends Path<Config>>(key: Key) => PathValue<Config, Key> | null;
153
+ getOrDefault: <Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>) => PathValue<Config, Key>;
154
+ getOrThrow: <Key extends Path<Config>>(key: Key, errorMessage?: string) => PathValue<Config, Key>;
155
+ }
156
+
10
157
  type ClassType = new (...args: any[]) => any;
11
158
  type ClassTypeWithInstance<T> = new (...args: any[]) => T;
12
159
  declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject> | unknown = unknown> {
@@ -237,145 +384,6 @@ declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: Injec
237
384
  declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
238
385
  declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
239
386
 
240
- interface ControllerOptions {
241
- guards?: ClassType[] | Set<ClassType>;
242
- }
243
- declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
244
-
245
- type EndpointParams<EndpointDeclaration extends {
246
- config: BaseEndpointConfig<any, any, any, any, any>;
247
- }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends AnyZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, QuerySchema, undefined> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, undefined, undefined>;
248
- declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
249
- config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
250
- }): (target: (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>;
251
-
252
- interface ModuleOptions {
253
- controllers?: ClassType[] | Set<ClassType>;
254
- imports?: ClassType[] | Set<ClassType>;
255
- guards?: ClassType[] | Set<ClassType>;
256
- }
257
- declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
258
-
259
- declare const EndpointMetadataKey: unique symbol;
260
- interface EndpointMetadata {
261
- classMethod: string;
262
- url: string;
263
- httpMethod: HttpMethod;
264
- config: BaseEndpointConfig | null;
265
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
266
- customAttributes: Map<string | symbol, any>;
267
- }
268
- declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
269
- declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
270
-
271
- declare const ControllerMetadataKey: unique symbol;
272
- interface ControllerMetadata {
273
- endpoints: Set<EndpointMetadata>;
274
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
275
- customAttributes: Map<string | symbol, any>;
276
- }
277
- declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
278
- declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
279
- declare function hasControllerMetadata(target: ClassType): boolean;
280
-
281
- interface InjectableMetadata<Instance = any, Schema = any> {
282
- type: InjectableType;
283
- scope: InjectableScope;
284
- token: InjectionToken<Instance, Schema>;
285
- }
286
-
287
- declare const ModuleMetadataKey: unique symbol;
288
- interface ModuleMetadata {
289
- controllers: Set<ClassType>;
290
- imports: Set<ClassType>;
291
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
292
- customAttributes: Map<string | symbol, any>;
293
- }
294
- declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
295
- declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
296
- declare function hasModuleMetadata(target: ClassType): boolean;
297
-
298
- declare class ExecutionContext {
299
- private readonly module;
300
- private readonly controller;
301
- private readonly handler;
302
- private request;
303
- private reply;
304
- constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
305
- getModule(): ModuleMetadata;
306
- getController(): ControllerMetadata;
307
- getHandler(): EndpointMetadata;
308
- getRequest(): FastifyRequest;
309
- getReply(): FastifyReply;
310
- provideRequest(request: FastifyRequest): void;
311
- provideReply(reply: FastifyReply): void;
312
- }
313
-
314
- declare class GuardRunnerService {
315
- runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: ExecutionContext): Promise<boolean>;
316
- makeContext(executionContext: ExecutionContext): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
317
- }
318
-
319
- declare class ControllerAdapterService {
320
- guardRunner: GuardRunnerService;
321
- private logger;
322
- setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
323
- }
324
-
325
- declare class ModuleLoaderService {
326
- private logger;
327
- private modulesMetadata;
328
- private loadedModules;
329
- private initialized;
330
- loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
331
- private traverseModules;
332
- private mergeMetadata;
333
- getAllModules(): Map<string, ModuleMetadata>;
334
- }
335
-
336
- interface CanActivate {
337
- canActivate(executionContext: ExecutionContext): Promise<boolean> | boolean;
338
- }
339
-
340
- interface NaviosModule {
341
- onModuleInit?: () => Promise<void> | void;
342
- }
343
-
344
- declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
345
-
346
- declare class HttpException {
347
- readonly statusCode: number;
348
- readonly response: string | object;
349
- readonly error?: Error | undefined;
350
- constructor(statusCode: number, response: string | object, error?: Error | undefined);
351
- }
352
-
353
- declare class BadRequestException extends HttpException {
354
- constructor(message: string | object);
355
- }
356
-
357
- declare class ForbiddenException extends HttpException {
358
- constructor(message: string);
359
- }
360
-
361
- declare class InternalServerErrorException extends HttpException {
362
- constructor(message: string | object, error?: Error);
363
- }
364
-
365
- declare class NotFoundException extends HttpException {
366
- readonly response: string | object;
367
- readonly error?: Error | undefined;
368
- constructor(response: string | object, error?: Error | undefined);
369
- }
370
-
371
- declare class UnauthorizedException extends HttpException {
372
- constructor(message: string | object, error?: Error);
373
- }
374
-
375
- declare class ConflictException extends HttpException {
376
- constructor(message: string | object, error?: Error);
377
- }
378
-
379
387
  declare const clc: {
380
388
  bold: (text: string) => string;
381
389
  green: (text: string) => string;
@@ -386,12 +394,6 @@ declare const clc: {
386
394
  };
387
395
  declare const yellow: (text: string) => string;
388
396
 
389
- declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
390
- /**
391
- * @publicApi
392
- */
393
- type LogLevel = (typeof LOG_LEVELS)[number];
394
-
395
397
  /**
396
398
  * @publicApi
397
399
  */
@@ -403,62 +405,27 @@ declare function filterLogLevels(parseableString?: string): LogLevel[];
403
405
  declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
404
406
 
405
407
  /**
406
- * Checks if target level is enabled.
407
- * @param targetLevel target level
408
- * @param logLevels array of enabled log levels
409
- */
410
- declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
411
-
412
- declare const isUndefined: (obj: any) => obj is undefined;
413
- declare const isObject: (fn: any) => fn is object;
414
- declare const isPlainObject: (fn: any) => fn is object;
415
- declare const addLeadingSlash: (path?: string) => string;
416
- declare const normalizePath: (path?: string) => string;
417
- declare const stripEndSlash: (path: string) => string;
418
- declare const isFunction: (val: any) => val is Function;
419
- declare const isString: (val: any) => val is string;
420
- declare const isNumber: (val: any) => val is number;
421
- declare const isConstructor: (val: any) => boolean;
422
- declare const isNil: (val: any) => val is null | undefined;
423
- declare const isEmpty: (array: any) => boolean;
424
- declare const isSymbol: (val: any) => val is symbol;
425
-
426
- /**
427
- * @publicApi
428
- */
429
- interface LoggerService {
430
- /**
431
- * Write a 'log' level log.
432
- */
433
- log(message: any, ...optionalParams: any[]): any;
434
- /**
435
- * Write an 'error' level log.
436
- */
437
- error(message: any, ...optionalParams: any[]): any;
438
- /**
439
- * Write a 'warn' level log.
440
- */
441
- warn(message: any, ...optionalParams: any[]): any;
442
- /**
443
- * Write a 'debug' level log.
444
- */
445
- debug?(message: any, ...optionalParams: any[]): any;
446
- /**
447
- * Write a 'verbose' level log.
448
- */
449
- verbose?(message: any, ...optionalParams: any[]): any;
450
- /**
451
- * Write a 'fatal' level log.
452
- */
453
- fatal?(message: any, ...optionalParams: any[]): any;
454
- /**
455
- * Set log levels.
456
- * @param levels log levels
457
- */
458
- setLogLevels?(levels: LogLevel[]): any;
459
- }
460
-
461
- /**
408
+ * Checks if target level is enabled.
409
+ * @param targetLevel target level
410
+ * @param logLevels array of enabled log levels
411
+ */
412
+ declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
413
+
414
+ declare const isUndefined: (obj: any) => obj is undefined;
415
+ declare const isObject: (fn: any) => fn is object;
416
+ declare const isPlainObject: (fn: any) => fn is object;
417
+ declare const addLeadingSlash: (path?: string) => string;
418
+ declare const normalizePath: (path?: string) => string;
419
+ declare const stripEndSlash: (path: string) => string;
420
+ declare const isFunction: (val: any) => val is Function;
421
+ declare const isString: (val: any) => val is string;
422
+ declare const isNumber: (val: any) => val is number;
423
+ declare const isConstructor: (val: any) => boolean;
424
+ declare const isNil: (val: any) => val is null | undefined;
425
+ declare const isEmpty: (array: any) => boolean;
426
+ declare const isSymbol: (val: any) => val is symbol;
427
+
428
+ /**
462
429
  * @publicApi
463
430
  */
464
431
  interface ConsoleLoggerOptions {
@@ -640,89 +607,6 @@ declare class ConsoleLogger implements LoggerService {
640
607
  private getColorByLogLevel;
641
608
  }
642
609
 
643
- declare class LoggerInstance implements LoggerService {
644
- protected context?: string | undefined;
645
- protected options: {
646
- timestamp?: boolean;
647
- };
648
- protected static staticInstanceRef?: LoggerService;
649
- protected static logLevels?: LogLevel[];
650
- protected localInstanceRef?: LoggerService;
651
- constructor();
652
- constructor(context: string);
653
- constructor(context: string, options?: {
654
- timestamp?: boolean;
655
- });
656
- get localInstance(): LoggerService;
657
- /**
658
- * Write an 'error' level log.
659
- */
660
- error(message: any, stack?: string, context?: string): void;
661
- error(message: any, ...optionalParams: [...any, string?, string?]): void;
662
- /**
663
- * Write a 'log' level log.
664
- */
665
- log(message: any, context?: string): void;
666
- log(message: any, ...optionalParams: [...any, string?]): void;
667
- /**
668
- * Write a 'warn' level log.
669
- */
670
- warn(message: any, context?: string): void;
671
- warn(message: any, ...optionalParams: [...any, string?]): void;
672
- /**
673
- * Write a 'debug' level log.
674
- */
675
- debug(message: any, context?: string): void;
676
- debug(message: any, ...optionalParams: [...any, string?]): void;
677
- /**
678
- * Write a 'verbose' level log.
679
- */
680
- verbose(message: any, context?: string): void;
681
- verbose(message: any, ...optionalParams: [...any, string?]): void;
682
- /**
683
- * Write a 'fatal' level log.
684
- */
685
- fatal(message: any, context?: string): void;
686
- fatal(message: any, ...optionalParams: [...any, string?]): void;
687
- /**
688
- * Write an 'error' level log.
689
- */
690
- static error(message: any, stackOrContext?: string): void;
691
- static error(message: any, context?: string): void;
692
- static error(message: any, stack?: string, context?: string): void;
693
- static error(message: any, ...optionalParams: [...any, string?, string?]): void;
694
- /**
695
- * Write a 'log' level log.
696
- */
697
- static log(message: any, context?: string): void;
698
- static log(message: any, ...optionalParams: [...any, string?]): void;
699
- /**
700
- * Write a 'warn' level log.
701
- */
702
- static warn(message: any, context?: string): void;
703
- static warn(message: any, ...optionalParams: [...any, string?]): void;
704
- /**
705
- * Write a 'debug' level log, if the configured level allows for it.
706
- * Prints to `stdout` with newline.
707
- */
708
- static debug(message: any, context?: string): void;
709
- static debug(message: any, ...optionalParams: [...any, string?]): void;
710
- /**
711
- * Write a 'verbose' level log.
712
- */
713
- static verbose(message: any, context?: string): void;
714
- static verbose(message: any, ...optionalParams: [...any, string?]): void;
715
- /**
716
- * Write a 'fatal' level log.
717
- */
718
- static fatal(message: any, context?: string): void;
719
- static fatal(message: any, ...optionalParams: [...any, string?]): void;
720
- static getTimestamp(): string;
721
- static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
722
- static isLevelEnabled(level: LogLevel): boolean;
723
- private registerLocalInstanceRef;
724
- }
725
-
726
610
  declare const LoggerInjectionToken = "LoggerInjectionToken";
727
611
  declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
728
612
  context: z.ZodOptional<z.ZodString>;
@@ -774,14 +658,200 @@ declare class PinoWrapper {
774
658
  fatal(message: any, ...optionalParams: any[]): void;
775
659
  error(message: any, ...optionalParams: any[]): void;
776
660
  warn(message: any, ...optionalParams: any[]): void;
777
- info(message: any, ...optionalParams: any[]): void;
661
+ info(): void;
778
662
  debug(message: any, ...optionalParams: any[]): void;
779
663
  trace(message: any, ...optionalParams: any[]): void;
780
- silent(message: any, ...optionalParams: any[]): void;
664
+ silent(): void;
781
665
  child(options: any): PinoWrapper;
782
666
  get level(): any;
783
667
  }
784
668
 
669
+ declare class ConfigServiceInstance<Config = Record<string, unknown>> implements ConfigService<Config> {
670
+ private config;
671
+ private logger;
672
+ constructor(config: Config | undefined, logger: LoggerService);
673
+ getConfig(): Config;
674
+ get<Key extends Path<Config>>(key: Key): PathValue<Config, Key> | null;
675
+ getOrDefault<Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>): PathValue<Config, Key>;
676
+ getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
677
+ }
678
+
679
+ declare const ConfigProviderInjectionToken = "ConfigProvider";
680
+ declare const ConfigProviderOptions: z.ZodObject<{
681
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
682
+ }, "strip", z.ZodTypeAny, {
683
+ load: (...args: unknown[]) => unknown;
684
+ }, {
685
+ load: (...args: unknown[]) => unknown;
686
+ }>;
687
+ declare const ConfigProvider: InjectionToken<ConfigService<Record<string, unknown>>, z.ZodObject<{
688
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
689
+ }, "strip", z.ZodTypeAny, {
690
+ load: (...args: unknown[]) => unknown;
691
+ }, {
692
+ load: (...args: unknown[]) => unknown;
693
+ }>>;
694
+ declare class ConfigProviderFactory {
695
+ logger: Promise<LoggerInstance>;
696
+ create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
697
+ }
698
+ declare function makeConfigToken<Config extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigService<Config>>;
699
+
700
+ interface ControllerOptions {
701
+ guards?: ClassType[] | Set<ClassType>;
702
+ }
703
+ declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
704
+
705
+ type EndpointParams<EndpointDeclaration extends {
706
+ config: BaseEndpointConfig<any, any, any, any, any>;
707
+ }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends AnyZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, QuerySchema, undefined> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, undefined, undefined>;
708
+ declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
709
+ config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
710
+ }): (target: (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>;
711
+
712
+ declare function Header(name: HttpHeader, value: string | number | string[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
713
+
714
+ declare function HttpCode(code: number): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
715
+
716
+ interface ModuleOptions {
717
+ controllers?: ClassType[] | Set<ClassType>;
718
+ imports?: ClassType[] | Set<ClassType>;
719
+ guards?: ClassType[] | Set<ClassType>;
720
+ }
721
+ declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
722
+
723
+ declare const EndpointMetadataKey: unique symbol;
724
+ declare enum EndpointType {
725
+ Unknown = "unknown",
726
+ Config = "config",
727
+ Handler = "handler"
728
+ }
729
+ interface EndpointMetadata {
730
+ classMethod: string;
731
+ url: string;
732
+ successStatusCode: number;
733
+ type: EndpointType;
734
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
735
+ httpMethod: HttpMethod;
736
+ config: BaseEndpointConfig | null;
737
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
738
+ customAttributes: Map<string | symbol, any>;
739
+ }
740
+ declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
741
+ declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
742
+
743
+ declare const ControllerMetadataKey: unique symbol;
744
+ interface ControllerMetadata {
745
+ endpoints: Set<EndpointMetadata>;
746
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
747
+ customAttributes: Map<string | symbol, any>;
748
+ }
749
+ declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
750
+ declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
751
+ declare function hasControllerMetadata(target: ClassType): boolean;
752
+
753
+ interface InjectableMetadata<Instance = any, Schema = any> {
754
+ type: InjectableType;
755
+ scope: InjectableScope;
756
+ token: InjectionToken<Instance, Schema>;
757
+ }
758
+
759
+ declare const ModuleMetadataKey: unique symbol;
760
+ interface ModuleMetadata {
761
+ controllers: Set<ClassType>;
762
+ imports: Set<ClassType>;
763
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
764
+ customAttributes: Map<string | symbol, any>;
765
+ }
766
+ declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
767
+ declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
768
+ declare function hasModuleMetadata(target: ClassType): boolean;
769
+
770
+ declare class ExecutionContext {
771
+ private readonly module;
772
+ private readonly controller;
773
+ private readonly handler;
774
+ private request;
775
+ private reply;
776
+ constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
777
+ getModule(): ModuleMetadata;
778
+ getController(): ControllerMetadata;
779
+ getHandler(): EndpointMetadata;
780
+ getRequest(): FastifyRequest;
781
+ getReply(): FastifyReply;
782
+ provideRequest(request: FastifyRequest): void;
783
+ provideReply(reply: FastifyReply): void;
784
+ }
785
+
786
+ declare class GuardRunnerService {
787
+ runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: ExecutionContext): Promise<boolean>;
788
+ makeContext(executionContext: ExecutionContext): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
789
+ }
790
+
791
+ declare class ControllerAdapterService {
792
+ guardRunner: GuardRunnerService;
793
+ private logger;
794
+ setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
795
+ providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<undefined>) | undefined;
796
+ private provideSchemaForConfig;
797
+ private provideHandler;
798
+ private provideHandlerForConfig;
799
+ }
800
+
801
+ declare class ModuleLoaderService {
802
+ private logger;
803
+ private modulesMetadata;
804
+ private loadedModules;
805
+ private initialized;
806
+ loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
807
+ private traverseModules;
808
+ private mergeMetadata;
809
+ getAllModules(): Map<string, ModuleMetadata>;
810
+ }
811
+
812
+ interface CanActivate {
813
+ canActivate(executionContext: ExecutionContext): Promise<boolean> | boolean;
814
+ }
815
+
816
+ interface NaviosModule {
817
+ onModuleInit?: () => Promise<void> | void;
818
+ }
819
+
820
+ declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
821
+
822
+ declare class HttpException {
823
+ readonly statusCode: number;
824
+ readonly response: string | object;
825
+ readonly error?: Error | undefined;
826
+ constructor(statusCode: number, response: string | object, error?: Error | undefined);
827
+ }
828
+
829
+ declare class BadRequestException extends HttpException {
830
+ constructor(message: string | object);
831
+ }
832
+
833
+ declare class ForbiddenException extends HttpException {
834
+ constructor(message: string);
835
+ }
836
+
837
+ declare class InternalServerErrorException extends HttpException {
838
+ constructor(message: string | object, error?: Error);
839
+ }
840
+
841
+ declare class NotFoundException extends HttpException {
842
+ readonly response: string | object;
843
+ readonly error?: Error | undefined;
844
+ constructor(response: string | object, error?: Error | undefined);
845
+ }
846
+
847
+ declare class UnauthorizedException extends HttpException {
848
+ constructor(message: string | object, error?: Error);
849
+ }
850
+
851
+ declare class ConflictException extends HttpException {
852
+ constructor(message: string | object, error?: Error);
853
+ }
854
+
785
855
  declare const Application: InjectionToken<FastifyInstance<fastify.RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>, undefined>;
786
856
 
787
857
  declare const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
@@ -831,6 +901,7 @@ declare class NaviosApplication {
831
901
  setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): void;
832
902
  init(): Promise<void>;
833
903
  private getFastifyInstance;
904
+ private configureFastifyInstance;
834
905
  private initModules;
835
906
  enableCors(options: FastifyCorsOptions): void;
836
907
  setGlobalPrefix(prefix: string): void;
@@ -843,4 +914,4 @@ declare class NaviosFactory {
843
914
  private static registerLoggerConfiguration;
844
915
  }
845
916
 
846
- export { Application, AttributeFactory, BadRequestException, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConflictException, ConsoleLogger, type ConsoleLoggerOptions, Controller, ControllerAdapterService, type ControllerMetadata, ControllerMetadataKey, type ControllerOptions, Endpoint, type EndpointMetadata, EndpointMetadataKey, type EndpointParams, ErrorsEnum, EventEmitter, type EventEmitterInterface, type EventsArgs, type EventsConfig, type EventsNames, ExecutionContext, ExecutionContextInjectionToken, ExecutionContextToken, FactoryNotFound, ForbiddenException, GuardRunnerService, HttpException, Injectable, type InjectableMetadata, type InjectableOptions, InjectableScope, InjectableTokenMeta, InjectableType, InjectionToken, InstanceDestroying, InstanceExpired, InstanceNotFound, InternalServerErrorException, LOG_LEVELS, type LogLevel, Logger, LoggerFactory, LoggerInjectionToken, LoggerInstance, LoggerOptions, type LoggerService, Module, ModuleLoaderService, type ModuleMetadata, ModuleMetadataKey, type ModuleOptions, NaviosApplication, type NaviosApplicationContextOptions, type NaviosApplicationOptions, NaviosFactory, type NaviosModule, NotFoundException, PinoWrapper, Reply, Request, ServiceLocator, type ServiceLocatorAbstractFactoryContext, ServiceLocatorEventBus, type ServiceLocatorInstanceDestroyListener, type ServiceLocatorInstanceEffect, type ServiceLocatorInstanceHolder, type ServiceLocatorInstanceHolderCreated, type ServiceLocatorInstanceHolderCreating, type ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnauthorizedException, UnknownError, UseGuards, addLeadingSlash, clc, extractControllerMetadata, extractModuleMetadata, filterLogLevels, getAllEndpointMetadata, getControllerMetadata, getEndpointMetadata, getInjectableToken, getModuleMetadata, getServiceLocator, hasControllerMetadata, hasModuleMetadata, inject, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, normalizePath, override, provideServiceLocator, setPromiseCollector, stripEndSlash, syncInject, yellow };
917
+ export { Application, AttributeFactory, BadRequestException, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConfigProvider, ConfigProviderFactory, ConfigProviderInjectionToken, ConfigProviderOptions, type ConfigService, ConfigServiceInstance, ConflictException, ConsoleLogger, type ConsoleLoggerOptions, Controller, ControllerAdapterService, type ControllerMetadata, ControllerMetadataKey, type ControllerOptions, Endpoint, type EndpointMetadata, EndpointMetadataKey, type EndpointParams, EndpointType, ErrorsEnum, EventEmitter, type EventEmitterInterface, type EventsArgs, type EventsConfig, type EventsNames, ExecutionContext, ExecutionContextInjectionToken, ExecutionContextToken, FactoryNotFound, ForbiddenException, GuardRunnerService, Header, HttpCode, HttpException, Injectable, type InjectableMetadata, type InjectableOptions, InjectableScope, InjectableTokenMeta, InjectableType, InjectionToken, InstanceDestroying, InstanceExpired, InstanceNotFound, InternalServerErrorException, LOG_LEVELS, type LogLevel, Logger, LoggerFactory, LoggerInjectionToken, LoggerInstance, LoggerOptions, type LoggerService, Module, ModuleLoaderService, type ModuleMetadata, ModuleMetadataKey, type ModuleOptions, NaviosApplication, type NaviosApplicationContextOptions, type NaviosApplicationOptions, NaviosFactory, type NaviosModule, NotFoundException, type Path, type PathImpl, type PathImpl2, type PathValue, PinoWrapper, Reply, Request, ServiceLocator, type ServiceLocatorAbstractFactoryContext, ServiceLocatorEventBus, type ServiceLocatorInstanceDestroyListener, type ServiceLocatorInstanceEffect, type ServiceLocatorInstanceHolder, type ServiceLocatorInstanceHolderCreated, type ServiceLocatorInstanceHolderCreating, type ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnauthorizedException, UnknownError, UseGuards, addLeadingSlash, clc, envInt, envString, extractControllerMetadata, extractModuleMetadata, filterLogLevels, getAllEndpointMetadata, getControllerMetadata, getEndpointMetadata, getInjectableToken, getModuleMetadata, getServiceLocator, hasControllerMetadata, hasModuleMetadata, inject, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, makeConfigToken, normalizePath, override, provideServiceLocator, setPromiseCollector, stripEndSlash, syncInject, yellow };