@navios/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +432 -11
- package/dist/index.d.ts +432 -11
- package/dist/index.js +798 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +771 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.mts +1 -0
- package/src/logger/README.md +3 -0
- package/src/logger/console-logger.service.mts +588 -0
- package/src/logger/index.mts +7 -0
- package/src/logger/log-levels.mts +12 -0
- package/src/logger/logger-service.interface.mts +42 -0
- package/src/logger/logger.factory.mts +37 -0
- package/src/logger/logger.service.mts +214 -0
- package/src/logger/pino-wrapper.mts +63 -0
- package/src/logger/utils/cli-colors.util.mts +17 -0
- package/src/logger/utils/filter-log-levelts.util.mts +29 -0
- package/src/logger/utils/index.mts +5 -0
- package/src/logger/utils/is-log-level-enabled.mts +33 -0
- package/src/logger/utils/is-log-level.util.mts +10 -0
- package/src/logger/utils/shared.utils.mts +51 -0
- package/src/navios.application.mts +71 -18
- package/src/navios.factory.mts +18 -1
- package/src/service-locator/inject.mts +6 -1
- package/src/service-locator/injection-token.mts +11 -6
- package/src/service-locator/service-locator.mts +44 -15
- package/src/service-locator/sync-injector.mts +6 -1
- package/src/services/controller-adapter.service.mts +8 -0
- package/src/services/module-loader.service.mts +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
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
|
|
|
9
10
|
type ClassType = new (...args: any[]) => any;
|
|
10
11
|
type ClassTypeWithInstance<T> = new (...args: any[]) => T;
|
|
11
|
-
declare class InjectionToken<T, S extends AnyZodObject | unknown = unknown> {
|
|
12
|
+
declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject> | unknown = unknown> {
|
|
12
13
|
readonly name: string | symbol | ClassType;
|
|
13
14
|
readonly schema: AnyZodObject | undefined;
|
|
14
15
|
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
15
16
|
constructor(name: string | symbol | ClassType, schema: AnyZodObject | undefined);
|
|
16
17
|
static create<T extends ClassType>(name: T): InjectionToken<InstanceType<T>, undefined>;
|
|
17
|
-
static create<T extends ClassType, Schema extends AnyZodObject
|
|
18
|
+
static create<T extends ClassType, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: T, schema: Schema): InjectionToken<InstanceType<T>, Schema>;
|
|
18
19
|
static create<T>(name: string): InjectionToken<T, undefined>;
|
|
19
|
-
static create<T, Schema extends AnyZodObject
|
|
20
|
+
static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string, schema: Schema): InjectionToken<T, Schema>;
|
|
20
21
|
toString(): string | symbol | ClassType;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -109,6 +110,7 @@ declare class EventEmitter<Events extends EventsConfig = {}> implements EventEmi
|
|
|
109
110
|
|
|
110
111
|
declare function inject<T extends ClassType>(token: T): Promise<InstanceType<T>>;
|
|
111
112
|
declare function inject<T, S extends AnyZodObject>(token: InjectionToken<T, S>, args: z.input<S>): Promise<T>;
|
|
113
|
+
declare function inject<T, S extends ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, args?: z.input<S>): Promise<T>;
|
|
112
114
|
declare function inject<T>(token: InjectionToken<T, undefined>): Promise<T>;
|
|
113
115
|
|
|
114
116
|
declare class ServiceLocatorEventBus {
|
|
@@ -141,15 +143,15 @@ declare class ServiceLocator {
|
|
|
141
143
|
getEventBus(): ServiceLocatorEventBus;
|
|
142
144
|
registerInstance<Instance>(token: InjectionToken<Instance, undefined>, instance: Instance): void;
|
|
143
145
|
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>;
|
|
146
|
+
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;
|
|
147
|
+
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;
|
|
148
|
+
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]>;
|
|
149
|
+
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
150
|
private notifyListeners;
|
|
149
151
|
private createInstance;
|
|
150
152
|
private createInstanceFromAbstractFactory;
|
|
151
153
|
private createContextForAbstractFactory;
|
|
152
|
-
getSyncInstance<Instance, Schema extends AnyZodObject | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : undefined): Instance | null;
|
|
154
|
+
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
155
|
invalidate(service: string, round?: number): Promise<any>;
|
|
154
156
|
ready(): Promise<null>;
|
|
155
157
|
makeInstanceName(token: InjectionToken<any, any>, args: any): string;
|
|
@@ -231,6 +233,7 @@ declare class ServiceLocatorManager {
|
|
|
231
233
|
declare let promiseCollector: null | ((promise: Promise<any>) => void);
|
|
232
234
|
declare function syncInject<T extends ClassType>(token: T): InstanceType<T>;
|
|
233
235
|
declare function syncInject<T, S extends AnyZodObject>(token: InjectionToken<T, S>, args: z.input<S>): T;
|
|
236
|
+
declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, args: z.input<S>): T;
|
|
234
237
|
declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
|
|
235
238
|
declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
|
|
236
239
|
|
|
@@ -315,10 +318,12 @@ declare class GuardRunnerService {
|
|
|
315
318
|
|
|
316
319
|
declare class ControllerAdapterService {
|
|
317
320
|
guardRunner: GuardRunnerService;
|
|
321
|
+
private logger;
|
|
318
322
|
setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
declare class ModuleLoaderService {
|
|
326
|
+
private logger;
|
|
322
327
|
private modulesMetadata;
|
|
323
328
|
private loadedModules;
|
|
324
329
|
private initialized;
|
|
@@ -371,6 +376,412 @@ declare class ConflictException extends HttpException {
|
|
|
371
376
|
constructor(message: string | object, error?: Error);
|
|
372
377
|
}
|
|
373
378
|
|
|
379
|
+
declare const clc: {
|
|
380
|
+
bold: (text: string) => string;
|
|
381
|
+
green: (text: string) => string;
|
|
382
|
+
yellow: (text: string) => string;
|
|
383
|
+
red: (text: string) => string;
|
|
384
|
+
magentaBright: (text: string) => string;
|
|
385
|
+
cyanBright: (text: string) => string;
|
|
386
|
+
};
|
|
387
|
+
declare const yellow: (text: string) => string;
|
|
388
|
+
|
|
389
|
+
declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
|
|
390
|
+
/**
|
|
391
|
+
* @publicApi
|
|
392
|
+
*/
|
|
393
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* @publicApi
|
|
397
|
+
*/
|
|
398
|
+
declare function filterLogLevels(parseableString?: string): LogLevel[];
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @publicApi
|
|
402
|
+
*/
|
|
403
|
+
declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
|
|
404
|
+
|
|
405
|
+
/**
|
|
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
|
+
/**
|
|
462
|
+
* @publicApi
|
|
463
|
+
*/
|
|
464
|
+
interface ConsoleLoggerOptions {
|
|
465
|
+
/**
|
|
466
|
+
* Enabled log levels.
|
|
467
|
+
*/
|
|
468
|
+
logLevels?: LogLevel[];
|
|
469
|
+
/**
|
|
470
|
+
* If enabled, will print timestamp (time difference) between current and previous log message.
|
|
471
|
+
* Note: This option is not used when `json` is enabled.
|
|
472
|
+
*/
|
|
473
|
+
timestamp?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* A prefix to be used for each log message.
|
|
476
|
+
* Note: This option is not used when `json` is enabled.
|
|
477
|
+
*/
|
|
478
|
+
prefix?: string;
|
|
479
|
+
/**
|
|
480
|
+
* If enabled, will print the log message in JSON format.
|
|
481
|
+
*/
|
|
482
|
+
json?: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* If enabled, will print the log message in color.
|
|
485
|
+
* Default true if json is disabled, false otherwise
|
|
486
|
+
*/
|
|
487
|
+
colors?: boolean;
|
|
488
|
+
/**
|
|
489
|
+
* The context of the logger.
|
|
490
|
+
*/
|
|
491
|
+
context?: string;
|
|
492
|
+
/**
|
|
493
|
+
* If enabled, will print the log message in a single line, even if it is an object with multiple properties.
|
|
494
|
+
* 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.
|
|
495
|
+
* Default true when `json` is enabled, false otherwise.
|
|
496
|
+
*/
|
|
497
|
+
compact?: boolean | number;
|
|
498
|
+
/**
|
|
499
|
+
* Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.
|
|
500
|
+
* Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.
|
|
501
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
502
|
+
* @default 100
|
|
503
|
+
*/
|
|
504
|
+
maxArrayLength?: number;
|
|
505
|
+
/**
|
|
506
|
+
* Specifies the maximum number of characters to include when formatting.
|
|
507
|
+
* Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.
|
|
508
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
509
|
+
* @default 10000.
|
|
510
|
+
*/
|
|
511
|
+
maxStringLength?: number;
|
|
512
|
+
/**
|
|
513
|
+
* If enabled, will sort keys while formatting objects.
|
|
514
|
+
* Can also be a custom sorting function.
|
|
515
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
516
|
+
* @default false
|
|
517
|
+
*/
|
|
518
|
+
sorted?: boolean | ((a: string, b: string) => number);
|
|
519
|
+
/**
|
|
520
|
+
* Specifies the number of times to recurse while formatting object. T
|
|
521
|
+
* This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
|
|
522
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
523
|
+
* @default 5
|
|
524
|
+
*/
|
|
525
|
+
depth?: number;
|
|
526
|
+
/**
|
|
527
|
+
* If true, object's non-enumerable symbols and properties are included in the formatted result.
|
|
528
|
+
* WeakMap and WeakSet entries are also included as well as user defined prototype properties
|
|
529
|
+
* @default false
|
|
530
|
+
*/
|
|
531
|
+
showHidden?: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* 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).
|
|
534
|
+
* Default Infinity when "compact" is true, 80 otherwise.
|
|
535
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
536
|
+
*/
|
|
537
|
+
breakLength?: number;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* @publicApi
|
|
541
|
+
*/
|
|
542
|
+
declare class ConsoleLogger implements LoggerService {
|
|
543
|
+
/**
|
|
544
|
+
* The options of the logger.
|
|
545
|
+
*/
|
|
546
|
+
protected options: ConsoleLoggerOptions;
|
|
547
|
+
/**
|
|
548
|
+
* The context of the logger (can be set manually or automatically inferred).
|
|
549
|
+
*/
|
|
550
|
+
protected context?: string;
|
|
551
|
+
/**
|
|
552
|
+
* The original context of the logger (set in the constructor).
|
|
553
|
+
*/
|
|
554
|
+
protected originalContext?: string;
|
|
555
|
+
/**
|
|
556
|
+
* The options used for the "inspect" method.
|
|
557
|
+
*/
|
|
558
|
+
protected inspectOptions: InspectOptions;
|
|
559
|
+
/**
|
|
560
|
+
* The last timestamp at which the log message was printed.
|
|
561
|
+
*/
|
|
562
|
+
protected static lastTimestampAt?: number;
|
|
563
|
+
constructor();
|
|
564
|
+
constructor(context: string);
|
|
565
|
+
constructor(options: ConsoleLoggerOptions);
|
|
566
|
+
constructor(context: string, options: ConsoleLoggerOptions);
|
|
567
|
+
/**
|
|
568
|
+
* Write a 'log' level log, if the configured level allows for it.
|
|
569
|
+
* Prints to `stdout` with newline.
|
|
570
|
+
*/
|
|
571
|
+
log(message: any, context?: string): void;
|
|
572
|
+
log(message: any, ...optionalParams: [...any, string?]): void;
|
|
573
|
+
/**
|
|
574
|
+
* Write an 'error' level log, if the configured level allows for it.
|
|
575
|
+
* Prints to `stderr` with newline.
|
|
576
|
+
*/
|
|
577
|
+
error(message: any, stackOrContext?: string): void;
|
|
578
|
+
error(message: any, stack?: string, context?: string): void;
|
|
579
|
+
error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
|
580
|
+
/**
|
|
581
|
+
* Write a 'warn' level log, if the configured level allows for it.
|
|
582
|
+
* Prints to `stdout` with newline.
|
|
583
|
+
*/
|
|
584
|
+
warn(message: any, context?: string): void;
|
|
585
|
+
warn(message: any, ...optionalParams: [...any, string?]): void;
|
|
586
|
+
/**
|
|
587
|
+
* Write a 'debug' level log, if the configured level allows for it.
|
|
588
|
+
* Prints to `stdout` with newline.
|
|
589
|
+
*/
|
|
590
|
+
debug(message: any, context?: string): void;
|
|
591
|
+
debug(message: any, ...optionalParams: [...any, string?]): void;
|
|
592
|
+
/**
|
|
593
|
+
* Write a 'verbose' level log, if the configured level allows for it.
|
|
594
|
+
* Prints to `stdout` with newline.
|
|
595
|
+
*/
|
|
596
|
+
verbose(message: any, context?: string): void;
|
|
597
|
+
verbose(message: any, ...optionalParams: [...any, string?]): void;
|
|
598
|
+
/**
|
|
599
|
+
* Write a 'fatal' level log, if the configured level allows for it.
|
|
600
|
+
* Prints to `stdout` with newline.
|
|
601
|
+
*/
|
|
602
|
+
fatal(message: any, context?: string): void;
|
|
603
|
+
fatal(message: any, ...optionalParams: [...any, string?]): void;
|
|
604
|
+
/**
|
|
605
|
+
* Set log levels
|
|
606
|
+
* @param levels log levels
|
|
607
|
+
*/
|
|
608
|
+
setLogLevels(levels: LogLevel[]): void;
|
|
609
|
+
/**
|
|
610
|
+
* Set logger context
|
|
611
|
+
* @param context context
|
|
612
|
+
*/
|
|
613
|
+
setContext(context: string): void;
|
|
614
|
+
/**
|
|
615
|
+
* Resets the logger context to the value that was passed in the constructor.
|
|
616
|
+
*/
|
|
617
|
+
resetContext(): void;
|
|
618
|
+
isLevelEnabled(level: LogLevel): boolean;
|
|
619
|
+
protected getTimestamp(): string;
|
|
620
|
+
protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr', errorStack?: unknown): void;
|
|
621
|
+
protected printAsJson(message: unknown, options: {
|
|
622
|
+
context: string;
|
|
623
|
+
logLevel: LogLevel;
|
|
624
|
+
writeStreamType?: 'stdout' | 'stderr';
|
|
625
|
+
errorStack?: unknown;
|
|
626
|
+
}): void;
|
|
627
|
+
protected formatPid(pid: number): string;
|
|
628
|
+
protected formatContext(context: string): string;
|
|
629
|
+
protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
|
630
|
+
protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
|
|
631
|
+
protected colorize(message: string, logLevel: LogLevel): string;
|
|
632
|
+
protected printStackTrace(stack: string): void;
|
|
633
|
+
protected updateAndGetTimestampDiff(): string;
|
|
634
|
+
protected formatTimestampDiff(timestampDiff: number): string;
|
|
635
|
+
protected getInspectOptions(): InspectOptions;
|
|
636
|
+
protected stringifyReplacer(key: string, value: unknown): unknown;
|
|
637
|
+
private getContextAndMessagesToPrint;
|
|
638
|
+
private getContextAndStackAndMessagesToPrint;
|
|
639
|
+
private isStackFormat;
|
|
640
|
+
private getColorByLogLevel;
|
|
641
|
+
}
|
|
642
|
+
|
|
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
|
+
declare const LoggerInjectionToken = "LoggerInjectionToken";
|
|
727
|
+
declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
|
|
728
|
+
context: z.ZodOptional<z.ZodString>;
|
|
729
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
730
|
+
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
731
|
+
}, "strip", z.ZodTypeAny, {
|
|
732
|
+
timestamp?: boolean | undefined;
|
|
733
|
+
}, {
|
|
734
|
+
timestamp?: boolean | undefined;
|
|
735
|
+
}>>;
|
|
736
|
+
}, "strip", z.ZodTypeAny, {
|
|
737
|
+
options?: {
|
|
738
|
+
timestamp?: boolean | undefined;
|
|
739
|
+
} | undefined;
|
|
740
|
+
context?: string | undefined;
|
|
741
|
+
}, {
|
|
742
|
+
options?: {
|
|
743
|
+
timestamp?: boolean | undefined;
|
|
744
|
+
} | undefined;
|
|
745
|
+
context?: string | undefined;
|
|
746
|
+
}>>;
|
|
747
|
+
declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
|
|
748
|
+
context: z.ZodOptional<z.ZodString>;
|
|
749
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
750
|
+
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
751
|
+
}, "strip", z.ZodTypeAny, {
|
|
752
|
+
timestamp?: boolean | undefined;
|
|
753
|
+
}, {
|
|
754
|
+
timestamp?: boolean | undefined;
|
|
755
|
+
}>>;
|
|
756
|
+
}, "strip", z.ZodTypeAny, {
|
|
757
|
+
options?: {
|
|
758
|
+
timestamp?: boolean | undefined;
|
|
759
|
+
} | undefined;
|
|
760
|
+
context?: string | undefined;
|
|
761
|
+
}, {
|
|
762
|
+
options?: {
|
|
763
|
+
timestamp?: boolean | undefined;
|
|
764
|
+
} | undefined;
|
|
765
|
+
context?: string | undefined;
|
|
766
|
+
}>>>;
|
|
767
|
+
declare class LoggerFactory {
|
|
768
|
+
create(ctx: any, args: z.infer<typeof LoggerOptions>): LoggerInstance;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
declare class PinoWrapper {
|
|
772
|
+
protected readonly logger: LoggerService;
|
|
773
|
+
constructor(logger: LoggerService);
|
|
774
|
+
fatal(message: any, ...optionalParams: any[]): void;
|
|
775
|
+
error(message: any, ...optionalParams: any[]): void;
|
|
776
|
+
warn(message: any, ...optionalParams: any[]): void;
|
|
777
|
+
info(message: any, ...optionalParams: any[]): void;
|
|
778
|
+
debug(message: any, ...optionalParams: any[]): void;
|
|
779
|
+
trace(message: any, ...optionalParams: any[]): void;
|
|
780
|
+
silent(message: any, ...optionalParams: any[]): void;
|
|
781
|
+
child(options: any): PinoWrapper;
|
|
782
|
+
get level(): any;
|
|
783
|
+
}
|
|
784
|
+
|
|
374
785
|
declare const Application: InjectionToken<FastifyInstance<fastify.RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>, undefined>;
|
|
375
786
|
|
|
376
787
|
declare const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
|
|
@@ -400,11 +811,18 @@ declare class AttributeFactory {
|
|
|
400
811
|
static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
|
|
401
812
|
}
|
|
402
813
|
|
|
403
|
-
interface
|
|
814
|
+
interface NaviosApplicationContextOptions {
|
|
815
|
+
/**
|
|
816
|
+
* Specifies the logger to use. Pass `false` to turn off logging.
|
|
817
|
+
*/
|
|
818
|
+
logger?: LoggerService | LogLevel[] | false;
|
|
819
|
+
}
|
|
820
|
+
interface NaviosApplicationOptions extends Omit<FastifyServerOptions, 'logger'>, NaviosApplicationContextOptions {
|
|
404
821
|
}
|
|
405
822
|
declare class NaviosApplication {
|
|
406
823
|
private moduleLoader;
|
|
407
824
|
private controllerAdapter;
|
|
825
|
+
private logger;
|
|
408
826
|
private server;
|
|
409
827
|
private corsOptions;
|
|
410
828
|
private globalPrefix;
|
|
@@ -412,6 +830,8 @@ declare class NaviosApplication {
|
|
|
412
830
|
private options;
|
|
413
831
|
setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): void;
|
|
414
832
|
init(): Promise<void>;
|
|
833
|
+
private getFastifyInstance;
|
|
834
|
+
private initModules;
|
|
415
835
|
enableCors(options: FastifyCorsOptions): void;
|
|
416
836
|
setGlobalPrefix(prefix: string): void;
|
|
417
837
|
getServer(): FastifyInstance;
|
|
@@ -420,6 +840,7 @@ declare class NaviosApplication {
|
|
|
420
840
|
|
|
421
841
|
declare class NaviosFactory {
|
|
422
842
|
static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): Promise<NaviosApplication>;
|
|
843
|
+
private static registerLoggerConfiguration;
|
|
423
844
|
}
|
|
424
845
|
|
|
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 };
|
|
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 };
|