@navios/core 0.1.0 → 0.1.2

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.
Files changed (38) hide show
  1. package/dist/index.d.mts +485 -11
  2. package/dist/index.d.ts +485 -11
  3. package/dist/index.js +1028 -136
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +993 -135
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/src/config/config-service.interface.mts +16 -0
  9. package/src/config/config.provider.mts +63 -0
  10. package/src/config/config.service.mts +69 -0
  11. package/src/config/index.mts +5 -0
  12. package/src/config/types.mts +58 -0
  13. package/src/config/utils/helpers.mts +23 -0
  14. package/src/config/utils/index.mts +1 -0
  15. package/src/index.mts +2 -0
  16. package/src/logger/README.md +3 -0
  17. package/src/logger/console-logger.service.mts +588 -0
  18. package/src/logger/index.mts +7 -0
  19. package/src/logger/log-levels.mts +12 -0
  20. package/src/logger/logger-service.interface.mts +42 -0
  21. package/src/logger/logger.factory.mts +37 -0
  22. package/src/logger/logger.service.mts +214 -0
  23. package/src/logger/pino-wrapper.mts +63 -0
  24. package/src/logger/utils/cli-colors.util.mts +17 -0
  25. package/src/logger/utils/filter-log-levelts.util.mts +29 -0
  26. package/src/logger/utils/index.mts +5 -0
  27. package/src/logger/utils/is-log-level-enabled.mts +33 -0
  28. package/src/logger/utils/is-log-level.util.mts +10 -0
  29. package/src/logger/utils/shared.utils.mts +51 -0
  30. package/src/navios.application.mts +71 -18
  31. package/src/navios.factory.mts +18 -1
  32. package/src/service-locator/inject.mts +6 -1
  33. package/src/service-locator/injection-token.mts +11 -6
  34. package/src/service-locator/proxy-service-locator.mts +28 -9
  35. package/src/service-locator/service-locator.mts +53 -16
  36. package/src/service-locator/sync-injector.mts +6 -1
  37. package/src/services/controller-adapter.service.mts +8 -0
  38. package/src/services/module-loader.service.mts +6 -1
package/dist/index.d.mts CHANGED
@@ -1,22 +1,169 @@
1
- import { AnyZodObject, z, ZodType } from 'zod';
1
+ import { AnyZodObject, ZodOptional, z, ZodType } from 'zod';
2
2
  import { BaseEndpointConfig, EndpointFunctionArgs, HttpMethod } from '@navios/common';
3
3
  import * as fastify from 'fastify';
4
4
  import { FastifyRequest, FastifyReply, FastifyInstance, FastifyServerOptions, FastifyListenOptions } from 'fastify';
5
+ import { InspectOptions } from 'util';
5
6
  import * as http from 'http';
6
7
  import * as fastify_types_type_provider_js from 'fastify/types/type-provider.js';
7
8
  import { FastifyCorsOptions } from '@fastify/cors';
8
9
 
10
+ declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
11
+ 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;
12
+
13
+ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
14
+ /**
15
+ * @publicApi
16
+ */
17
+ type LogLevel = (typeof LOG_LEVELS)[number];
18
+
19
+ /**
20
+ * @publicApi
21
+ */
22
+ interface LoggerService {
23
+ /**
24
+ * Write a 'log' level log.
25
+ */
26
+ log(message: any, ...optionalParams: any[]): any;
27
+ /**
28
+ * Write an 'error' level log.
29
+ */
30
+ error(message: any, ...optionalParams: any[]): any;
31
+ /**
32
+ * Write a 'warn' level log.
33
+ */
34
+ warn(message: any, ...optionalParams: any[]): any;
35
+ /**
36
+ * Write a 'debug' level log.
37
+ */
38
+ debug?(message: any, ...optionalParams: any[]): any;
39
+ /**
40
+ * Write a 'verbose' level log.
41
+ */
42
+ verbose?(message: any, ...optionalParams: any[]): any;
43
+ /**
44
+ * Write a 'fatal' level log.
45
+ */
46
+ fatal?(message: any, ...optionalParams: any[]): any;
47
+ /**
48
+ * Set log levels.
49
+ * @param levels log levels
50
+ */
51
+ setLogLevels?(levels: LogLevel[]): any;
52
+ }
53
+
54
+ declare class LoggerInstance implements LoggerService {
55
+ protected context?: string | undefined;
56
+ protected options: {
57
+ timestamp?: boolean;
58
+ };
59
+ protected static staticInstanceRef?: LoggerService;
60
+ protected static logLevels?: LogLevel[];
61
+ protected localInstanceRef?: LoggerService;
62
+ constructor();
63
+ constructor(context: string);
64
+ constructor(context: string, options?: {
65
+ timestamp?: boolean;
66
+ });
67
+ get localInstance(): LoggerService;
68
+ /**
69
+ * Write an 'error' level log.
70
+ */
71
+ error(message: any, stack?: string, context?: string): void;
72
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
73
+ /**
74
+ * Write a 'log' level log.
75
+ */
76
+ log(message: any, context?: string): void;
77
+ log(message: any, ...optionalParams: [...any, string?]): void;
78
+ /**
79
+ * Write a 'warn' level log.
80
+ */
81
+ warn(message: any, context?: string): void;
82
+ warn(message: any, ...optionalParams: [...any, string?]): void;
83
+ /**
84
+ * Write a 'debug' level log.
85
+ */
86
+ debug(message: any, context?: string): void;
87
+ debug(message: any, ...optionalParams: [...any, string?]): void;
88
+ /**
89
+ * Write a 'verbose' level log.
90
+ */
91
+ verbose(message: any, context?: string): void;
92
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
93
+ /**
94
+ * Write a 'fatal' level log.
95
+ */
96
+ fatal(message: any, context?: string): void;
97
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
98
+ /**
99
+ * Write an 'error' level log.
100
+ */
101
+ static error(message: any, stackOrContext?: string): void;
102
+ static error(message: any, context?: string): void;
103
+ static error(message: any, stack?: string, context?: string): void;
104
+ static error(message: any, ...optionalParams: [...any, string?, string?]): void;
105
+ /**
106
+ * Write a 'log' level log.
107
+ */
108
+ static log(message: any, context?: string): void;
109
+ static log(message: any, ...optionalParams: [...any, string?]): void;
110
+ /**
111
+ * Write a 'warn' level log.
112
+ */
113
+ static warn(message: any, context?: string): void;
114
+ static warn(message: any, ...optionalParams: [...any, string?]): void;
115
+ /**
116
+ * Write a 'debug' level log, if the configured level allows for it.
117
+ * Prints to `stdout` with newline.
118
+ */
119
+ static debug(message: any, context?: string): void;
120
+ static debug(message: any, ...optionalParams: [...any, string?]): void;
121
+ /**
122
+ * Write a 'verbose' level log.
123
+ */
124
+ static verbose(message: any, context?: string): void;
125
+ static verbose(message: any, ...optionalParams: [...any, string?]): void;
126
+ /**
127
+ * Write a 'fatal' level log.
128
+ */
129
+ static fatal(message: any, context?: string): void;
130
+ static fatal(message: any, ...optionalParams: [...any, string?]): void;
131
+ static getTimestamp(): string;
132
+ static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
133
+ static isLevelEnabled(level: LogLevel): boolean;
134
+ private registerLocalInstanceRef;
135
+ }
136
+
137
+ /**
138
+ * Evaluates to `true` if `T` is `any`. `false` otherwise.
139
+ * (c) https://stackoverflow.com/a/68633327/5290447
140
+ */
141
+ type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
142
+ type ExcludedParts = 'services' | 'mailer' | 'aws' | 'computedTimeRates' | 'aiModelsRates';
143
+ type ExcludedKeys = 'computedTimeRates' | 'aiModelsRates' | 'aiModel';
144
+ 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;
145
+ type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
146
+ type Path<T> = keyof T extends string ? PathImpl2<T> extends infer P ? P extends string | keyof T ? P : keyof T : keyof T : never;
147
+ 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;
148
+
149
+ interface ConfigService<Config = Record<string, unknown>> {
150
+ getConfig: () => Config;
151
+ get: <Key extends Path<Config>>(key: Key) => PathValue<Config, Key> | null;
152
+ getOrDefault: <Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>) => PathValue<Config, Key>;
153
+ getOrThrow: <Key extends Path<Config>>(key: Key, errorMessage?: string) => PathValue<Config, Key>;
154
+ }
155
+
9
156
  type ClassType = new (...args: any[]) => any;
10
157
  type ClassTypeWithInstance<T> = new (...args: any[]) => T;
11
- declare class InjectionToken<T, S extends AnyZodObject | unknown = unknown> {
158
+ declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject> | unknown = unknown> {
12
159
  readonly name: string | symbol | ClassType;
13
160
  readonly schema: AnyZodObject | undefined;
14
161
  id: `${string}-${string}-${string}-${string}-${string}`;
15
162
  constructor(name: string | symbol | ClassType, schema: AnyZodObject | undefined);
16
163
  static create<T extends ClassType>(name: T): InjectionToken<InstanceType<T>, undefined>;
17
- static create<T extends ClassType, Schema extends AnyZodObject>(name: T, schema: Schema): InjectionToken<InstanceType<T>, Schema>;
164
+ static create<T extends ClassType, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: T, schema: Schema): InjectionToken<InstanceType<T>, Schema>;
18
165
  static create<T>(name: string): InjectionToken<T, undefined>;
19
- static create<T, Schema extends AnyZodObject>(name: string, schema: Schema): InjectionToken<T, Schema>;
166
+ static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string, schema: Schema): InjectionToken<T, Schema>;
20
167
  toString(): string | symbol | ClassType;
21
168
  }
22
169
 
@@ -109,6 +256,7 @@ declare class EventEmitter<Events extends EventsConfig = {}> implements EventEmi
109
256
 
110
257
  declare function inject<T extends ClassType>(token: T): Promise<InstanceType<T>>;
111
258
  declare function inject<T, S extends AnyZodObject>(token: InjectionToken<T, S>, args: z.input<S>): Promise<T>;
259
+ declare function inject<T, S extends ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, args?: z.input<S>): Promise<T>;
112
260
  declare function inject<T>(token: InjectionToken<T, undefined>): Promise<T>;
113
261
 
114
262
  declare class ServiceLocatorEventBus {
@@ -141,15 +289,15 @@ declare class ServiceLocator {
141
289
  getEventBus(): ServiceLocatorEventBus;
142
290
  registerInstance<Instance>(token: InjectionToken<Instance, undefined>, instance: Instance): void;
143
291
  removeInstance<Instance>(token: InjectionToken<Instance, undefined>): Promise<any>;
144
- registerAbstractFactory<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, factory: (ctx: ServiceLocatorAbstractFactoryContext, values: Schema extends AnyZodObject ? z.output<Schema> : undefined) => Promise<Instance>, type?: InjectableScope): void;
145
- getInstanceIdentifier<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : undefined): string;
146
- getInstance<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : undefined): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
147
- getOrThrowInstance<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : undefined): Promise<Instance>;
292
+ registerAbstractFactory<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, factory: (ctx: ServiceLocatorAbstractFactoryContext, values: Schema extends AnyZodObject ? z.output<Schema> : undefined) => Promise<Instance>, type?: InjectableScope): void;
293
+ getInstanceIdentifier<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): string;
294
+ getInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
295
+ getOrThrowInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Promise<Instance>;
148
296
  private notifyListeners;
149
297
  private createInstance;
150
298
  private createInstanceFromAbstractFactory;
151
299
  private createContextForAbstractFactory;
152
- getSyncInstance<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : undefined): Instance | null;
300
+ getSyncInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Instance | null;
153
301
  invalidate(service: string, round?: number): Promise<any>;
154
302
  ready(): Promise<null>;
155
303
  makeInstanceName(token: InjectionToken<any, any>, args: any): string;
@@ -231,9 +379,323 @@ declare class ServiceLocatorManager {
231
379
  declare let promiseCollector: null | ((promise: Promise<any>) => void);
232
380
  declare function syncInject<T extends ClassType>(token: T): InstanceType<T>;
233
381
  declare function syncInject<T, S extends AnyZodObject>(token: InjectionToken<T, S>, args: z.input<S>): T;
382
+ declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, args: z.input<S>): T;
234
383
  declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
235
384
  declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
236
385
 
386
+ declare const clc: {
387
+ bold: (text: string) => string;
388
+ green: (text: string) => string;
389
+ yellow: (text: string) => string;
390
+ red: (text: string) => string;
391
+ magentaBright: (text: string) => string;
392
+ cyanBright: (text: string) => string;
393
+ };
394
+ declare const yellow: (text: string) => string;
395
+
396
+ /**
397
+ * @publicApi
398
+ */
399
+ declare function filterLogLevels(parseableString?: string): LogLevel[];
400
+
401
+ /**
402
+ * @publicApi
403
+ */
404
+ declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
405
+
406
+ /**
407
+ * Checks if target level is enabled.
408
+ * @param targetLevel target level
409
+ * @param logLevels array of enabled log levels
410
+ */
411
+ declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
412
+
413
+ declare const isUndefined: (obj: any) => obj is undefined;
414
+ declare const isObject: (fn: any) => fn is object;
415
+ declare const isPlainObject: (fn: any) => fn is object;
416
+ declare const addLeadingSlash: (path?: string) => string;
417
+ declare const normalizePath: (path?: string) => string;
418
+ declare const stripEndSlash: (path: string) => string;
419
+ declare const isFunction: (val: any) => val is Function;
420
+ declare const isString: (val: any) => val is string;
421
+ declare const isNumber: (val: any) => val is number;
422
+ declare const isConstructor: (val: any) => boolean;
423
+ declare const isNil: (val: any) => val is null | undefined;
424
+ declare const isEmpty: (array: any) => boolean;
425
+ declare const isSymbol: (val: any) => val is symbol;
426
+
427
+ /**
428
+ * @publicApi
429
+ */
430
+ interface ConsoleLoggerOptions {
431
+ /**
432
+ * Enabled log levels.
433
+ */
434
+ logLevels?: LogLevel[];
435
+ /**
436
+ * If enabled, will print timestamp (time difference) between current and previous log message.
437
+ * Note: This option is not used when `json` is enabled.
438
+ */
439
+ timestamp?: boolean;
440
+ /**
441
+ * A prefix to be used for each log message.
442
+ * Note: This option is not used when `json` is enabled.
443
+ */
444
+ prefix?: string;
445
+ /**
446
+ * If enabled, will print the log message in JSON format.
447
+ */
448
+ json?: boolean;
449
+ /**
450
+ * If enabled, will print the log message in color.
451
+ * Default true if json is disabled, false otherwise
452
+ */
453
+ colors?: boolean;
454
+ /**
455
+ * The context of the logger.
456
+ */
457
+ context?: string;
458
+ /**
459
+ * If enabled, will print the log message in a single line, even if it is an object with multiple properties.
460
+ * If set to a number, the most n inner elements are united on a single line as long as all properties fit into breakLength. Short array elements are also grouped together.
461
+ * Default true when `json` is enabled, false otherwise.
462
+ */
463
+ compact?: boolean | number;
464
+ /**
465
+ * Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.
466
+ * Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.
467
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
468
+ * @default 100
469
+ */
470
+ maxArrayLength?: number;
471
+ /**
472
+ * Specifies the maximum number of characters to include when formatting.
473
+ * Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.
474
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
475
+ * @default 10000.
476
+ */
477
+ maxStringLength?: number;
478
+ /**
479
+ * If enabled, will sort keys while formatting objects.
480
+ * Can also be a custom sorting function.
481
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
482
+ * @default false
483
+ */
484
+ sorted?: boolean | ((a: string, b: string) => number);
485
+ /**
486
+ * Specifies the number of times to recurse while formatting object. T
487
+ * This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
488
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
489
+ * @default 5
490
+ */
491
+ depth?: number;
492
+ /**
493
+ * If true, object's non-enumerable symbols and properties are included in the formatted result.
494
+ * WeakMap and WeakSet entries are also included as well as user defined prototype properties
495
+ * @default false
496
+ */
497
+ showHidden?: boolean;
498
+ /**
499
+ * The length at which input values are split across multiple lines. Set to Infinity to format the input as a single line (in combination with "compact" set to true).
500
+ * Default Infinity when "compact" is true, 80 otherwise.
501
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
502
+ */
503
+ breakLength?: number;
504
+ }
505
+ /**
506
+ * @publicApi
507
+ */
508
+ declare class ConsoleLogger implements LoggerService {
509
+ /**
510
+ * The options of the logger.
511
+ */
512
+ protected options: ConsoleLoggerOptions;
513
+ /**
514
+ * The context of the logger (can be set manually or automatically inferred).
515
+ */
516
+ protected context?: string;
517
+ /**
518
+ * The original context of the logger (set in the constructor).
519
+ */
520
+ protected originalContext?: string;
521
+ /**
522
+ * The options used for the "inspect" method.
523
+ */
524
+ protected inspectOptions: InspectOptions;
525
+ /**
526
+ * The last timestamp at which the log message was printed.
527
+ */
528
+ protected static lastTimestampAt?: number;
529
+ constructor();
530
+ constructor(context: string);
531
+ constructor(options: ConsoleLoggerOptions);
532
+ constructor(context: string, options: ConsoleLoggerOptions);
533
+ /**
534
+ * Write a 'log' level log, if the configured level allows for it.
535
+ * Prints to `stdout` with newline.
536
+ */
537
+ log(message: any, context?: string): void;
538
+ log(message: any, ...optionalParams: [...any, string?]): void;
539
+ /**
540
+ * Write an 'error' level log, if the configured level allows for it.
541
+ * Prints to `stderr` with newline.
542
+ */
543
+ error(message: any, stackOrContext?: string): void;
544
+ error(message: any, stack?: string, context?: string): void;
545
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
546
+ /**
547
+ * Write a 'warn' level log, if the configured level allows for it.
548
+ * Prints to `stdout` with newline.
549
+ */
550
+ warn(message: any, context?: string): void;
551
+ warn(message: any, ...optionalParams: [...any, string?]): void;
552
+ /**
553
+ * Write a 'debug' level log, if the configured level allows for it.
554
+ * Prints to `stdout` with newline.
555
+ */
556
+ debug(message: any, context?: string): void;
557
+ debug(message: any, ...optionalParams: [...any, string?]): void;
558
+ /**
559
+ * Write a 'verbose' level log, if the configured level allows for it.
560
+ * Prints to `stdout` with newline.
561
+ */
562
+ verbose(message: any, context?: string): void;
563
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
564
+ /**
565
+ * Write a 'fatal' level log, if the configured level allows for it.
566
+ * Prints to `stdout` with newline.
567
+ */
568
+ fatal(message: any, context?: string): void;
569
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
570
+ /**
571
+ * Set log levels
572
+ * @param levels log levels
573
+ */
574
+ setLogLevels(levels: LogLevel[]): void;
575
+ /**
576
+ * Set logger context
577
+ * @param context context
578
+ */
579
+ setContext(context: string): void;
580
+ /**
581
+ * Resets the logger context to the value that was passed in the constructor.
582
+ */
583
+ resetContext(): void;
584
+ isLevelEnabled(level: LogLevel): boolean;
585
+ protected getTimestamp(): string;
586
+ protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr', errorStack?: unknown): void;
587
+ protected printAsJson(message: unknown, options: {
588
+ context: string;
589
+ logLevel: LogLevel;
590
+ writeStreamType?: 'stdout' | 'stderr';
591
+ errorStack?: unknown;
592
+ }): void;
593
+ protected formatPid(pid: number): string;
594
+ protected formatContext(context: string): string;
595
+ protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
596
+ protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
597
+ protected colorize(message: string, logLevel: LogLevel): string;
598
+ protected printStackTrace(stack: string): void;
599
+ protected updateAndGetTimestampDiff(): string;
600
+ protected formatTimestampDiff(timestampDiff: number): string;
601
+ protected getInspectOptions(): InspectOptions;
602
+ protected stringifyReplacer(key: string, value: unknown): unknown;
603
+ private getContextAndMessagesToPrint;
604
+ private getContextAndStackAndMessagesToPrint;
605
+ private isStackFormat;
606
+ private getColorByLogLevel;
607
+ }
608
+
609
+ declare const LoggerInjectionToken = "LoggerInjectionToken";
610
+ declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
611
+ context: z.ZodOptional<z.ZodString>;
612
+ options: z.ZodOptional<z.ZodObject<{
613
+ timestamp: z.ZodOptional<z.ZodBoolean>;
614
+ }, "strip", z.ZodTypeAny, {
615
+ timestamp?: boolean | undefined;
616
+ }, {
617
+ timestamp?: boolean | undefined;
618
+ }>>;
619
+ }, "strip", z.ZodTypeAny, {
620
+ options?: {
621
+ timestamp?: boolean | undefined;
622
+ } | undefined;
623
+ context?: string | undefined;
624
+ }, {
625
+ options?: {
626
+ timestamp?: boolean | undefined;
627
+ } | undefined;
628
+ context?: string | undefined;
629
+ }>>;
630
+ declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
631
+ context: z.ZodOptional<z.ZodString>;
632
+ options: z.ZodOptional<z.ZodObject<{
633
+ timestamp: z.ZodOptional<z.ZodBoolean>;
634
+ }, "strip", z.ZodTypeAny, {
635
+ timestamp?: boolean | undefined;
636
+ }, {
637
+ timestamp?: boolean | undefined;
638
+ }>>;
639
+ }, "strip", z.ZodTypeAny, {
640
+ options?: {
641
+ timestamp?: boolean | undefined;
642
+ } | undefined;
643
+ context?: string | undefined;
644
+ }, {
645
+ options?: {
646
+ timestamp?: boolean | undefined;
647
+ } | undefined;
648
+ context?: string | undefined;
649
+ }>>>;
650
+ declare class LoggerFactory {
651
+ create(ctx: any, args: z.infer<typeof LoggerOptions>): LoggerInstance;
652
+ }
653
+
654
+ declare class PinoWrapper {
655
+ protected readonly logger: LoggerService;
656
+ constructor(logger: LoggerService);
657
+ fatal(message: any, ...optionalParams: any[]): void;
658
+ error(message: any, ...optionalParams: any[]): void;
659
+ warn(message: any, ...optionalParams: any[]): void;
660
+ info(message: any, ...optionalParams: any[]): void;
661
+ debug(message: any, ...optionalParams: any[]): void;
662
+ trace(message: any, ...optionalParams: any[]): void;
663
+ silent(message: any, ...optionalParams: any[]): void;
664
+ child(options: any): PinoWrapper;
665
+ get level(): any;
666
+ }
667
+
668
+ declare class ConfigServiceInstance<Config = Record<string, unknown>> implements ConfigService<Config> {
669
+ private config;
670
+ private logger;
671
+ constructor(config: Config | undefined, logger: LoggerService);
672
+ getConfig(): Config;
673
+ get<Key extends Path<Config>>(key: Key): PathValue<Config, Key> | null;
674
+ getOrDefault<Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>): PathValue<Config, Key>;
675
+ getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
676
+ }
677
+
678
+ declare const ConfigProviderInjectionToken = "ConfigProvider";
679
+ declare const ConfigProviderOptions: z.ZodObject<{
680
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
681
+ }, "strip", z.ZodTypeAny, {
682
+ load: (...args: unknown[]) => unknown;
683
+ }, {
684
+ load: (...args: unknown[]) => unknown;
685
+ }>;
686
+ declare const ConfigProvider: InjectionToken<ConfigService<Record<string, unknown>>, z.ZodObject<{
687
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
688
+ }, "strip", z.ZodTypeAny, {
689
+ load: (...args: unknown[]) => unknown;
690
+ }, {
691
+ load: (...args: unknown[]) => unknown;
692
+ }>>;
693
+ declare class ConfigProviderFactory {
694
+ logger: Promise<LoggerInstance>;
695
+ create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
696
+ }
697
+ declare function makeConfigToken<Config extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigService<Config>>;
698
+
237
699
  interface ControllerOptions {
238
700
  guards?: ClassType[] | Set<ClassType>;
239
701
  }
@@ -315,10 +777,12 @@ declare class GuardRunnerService {
315
777
 
316
778
  declare class ControllerAdapterService {
317
779
  guardRunner: GuardRunnerService;
780
+ private logger;
318
781
  setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
319
782
  }
320
783
 
321
784
  declare class ModuleLoaderService {
785
+ private logger;
322
786
  private modulesMetadata;
323
787
  private loadedModules;
324
788
  private initialized;
@@ -400,11 +864,18 @@ declare class AttributeFactory {
400
864
  static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
401
865
  }
402
866
 
403
- interface NaviosApplicationOptions extends FastifyServerOptions {
867
+ interface NaviosApplicationContextOptions {
868
+ /**
869
+ * Specifies the logger to use. Pass `false` to turn off logging.
870
+ */
871
+ logger?: LoggerService | LogLevel[] | false;
872
+ }
873
+ interface NaviosApplicationOptions extends Omit<FastifyServerOptions, 'logger'>, NaviosApplicationContextOptions {
404
874
  }
405
875
  declare class NaviosApplication {
406
876
  private moduleLoader;
407
877
  private controllerAdapter;
878
+ private logger;
408
879
  private server;
409
880
  private corsOptions;
410
881
  private globalPrefix;
@@ -412,6 +883,8 @@ declare class NaviosApplication {
412
883
  private options;
413
884
  setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): void;
414
885
  init(): Promise<void>;
886
+ private getFastifyInstance;
887
+ private initModules;
415
888
  enableCors(options: FastifyCorsOptions): void;
416
889
  setGlobalPrefix(prefix: string): void;
417
890
  getServer(): FastifyInstance;
@@ -420,6 +893,7 @@ declare class NaviosApplication {
420
893
 
421
894
  declare class NaviosFactory {
422
895
  static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): Promise<NaviosApplication>;
896
+ private static registerLoggerConfiguration;
423
897
  }
424
898
 
425
- export { Application, AttributeFactory, BadRequestException, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConflictException, 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, Module, ModuleLoaderService, type ModuleMetadata, ModuleMetadataKey, type ModuleOptions, NaviosApplication, type NaviosApplicationOptions, NaviosFactory, type NaviosModule, NotFoundException, Reply, Request, ServiceLocator, type ServiceLocatorAbstractFactoryContext, ServiceLocatorEventBus, type ServiceLocatorInstanceDestroyListener, type ServiceLocatorInstanceEffect, type ServiceLocatorInstanceHolder, type ServiceLocatorInstanceHolderCreated, type ServiceLocatorInstanceHolderCreating, type ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnauthorizedException, UnknownError, UseGuards, extractControllerMetadata, extractModuleMetadata, getAllEndpointMetadata, getControllerMetadata, getEndpointMetadata, getInjectableToken, getModuleMetadata, getServiceLocator, hasControllerMetadata, hasModuleMetadata, inject, override, provideServiceLocator, setPromiseCollector, syncInject };
899
+ 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, 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, 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 };