@navios/core 0.1.2 → 0.1.4

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 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';
@@ -162,12 +163,27 @@ declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObjec
162
163
  constructor(name: string | symbol | ClassType, schema: AnyZodObject | undefined);
163
164
  static create<T extends ClassType>(name: T): InjectionToken<InstanceType<T>, undefined>;
164
165
  static create<T extends ClassType, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: T, schema: Schema): InjectionToken<InstanceType<T>, Schema>;
165
- static create<T>(name: string): InjectionToken<T, undefined>;
166
- static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string, schema: Schema): InjectionToken<T, Schema>;
167
- toString(): string | symbol | ClassType;
168
- }
169
-
170
- declare function getInjectableToken<R, T extends ClassTypeWithInstance<R>>(target: ClassType): R extends {
166
+ static create<T>(name: string | symbol): InjectionToken<T, undefined>;
167
+ static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string | any, schema: Schema): InjectionToken<T, Schema>;
168
+ static bound<T, S extends AnyZodObject | ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, value: z.input<S>): BoundInjectionToken<T, S>;
169
+ static factory<T, S extends AnyZodObject | ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, factory: () => Promise<z.input<S>>): FactoryInjectionToken<T, S>;
170
+ static refineType<T>(token: BoundInjectionToken<any, any>): BoundInjectionToken<T, any>;
171
+ }
172
+ declare class BoundInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, undefined> {
173
+ readonly token: InjectionToken<T, S>;
174
+ readonly value: z.input<S>;
175
+ constructor(token: InjectionToken<T, S>, value: z.input<S>);
176
+ }
177
+ declare class FactoryInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, S> {
178
+ readonly token: InjectionToken<T, S>;
179
+ readonly factory: () => Promise<z.input<S>>;
180
+ value?: z.input<S>;
181
+ resolved: boolean;
182
+ constructor(token: InjectionToken<T, S>, factory: () => Promise<z.input<S>>);
183
+ resolve(): Promise<z.input<S>>;
184
+ }
185
+
186
+ declare function getInjectableToken<R>(target: ClassType): R extends {
171
187
  create(...args: any[]): infer V;
172
188
  } ? InjectionToken<V> : InjectionToken<R>;
173
189
 
@@ -199,7 +215,8 @@ declare enum ErrorsEnum {
199
215
  InstanceNotFound = "InstanceNotFound",
200
216
  InstanceDestroying = "InstanceDestroying",
201
217
  UnknownError = "UnknownError",
202
- FactoryNotFound = "FactoryNotFound"
218
+ FactoryNotFound = "FactoryNotFound",
219
+ FactoryTokenNotResolved = "FactoryTokenNotResolved"
203
220
  }
204
221
 
205
222
  declare class FactoryNotFound extends Error {
@@ -208,6 +225,11 @@ declare class FactoryNotFound extends Error {
208
225
  constructor(name: string);
209
226
  }
210
227
 
228
+ declare class FactoryTokenNotResolved extends Error {
229
+ code: ErrorsEnum;
230
+ constructor(name: string | symbol | ClassType);
231
+ }
232
+
211
233
  declare class InstanceDestroying extends Error {
212
234
  name: string;
213
235
  code: ErrorsEnum;
@@ -290,6 +312,7 @@ declare class ServiceLocator {
290
312
  registerInstance<Instance>(token: InjectionToken<Instance, undefined>, instance: Instance): void;
291
313
  removeInstance<Instance>(token: InjectionToken<Instance, undefined>): Promise<any>;
292
314
  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;
315
+ private resolveTokenArgs;
293
316
  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
317
  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
318
  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>;
@@ -383,6 +406,8 @@ declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: Injec
383
406
  declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
384
407
  declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
385
408
 
409
+ declare function resolveService<T extends ClassType>(ctx: ServiceLocatorAbstractFactoryContext, target: T, args?: any[]): Promise<InstanceType<T>>;
410
+
386
411
  declare const clc: {
387
412
  bold: (text: string) => string;
388
413
  green: (text: string) => string;
@@ -657,10 +682,10 @@ declare class PinoWrapper {
657
682
  fatal(message: any, ...optionalParams: any[]): void;
658
683
  error(message: any, ...optionalParams: any[]): void;
659
684
  warn(message: any, ...optionalParams: any[]): void;
660
- info(message: any, ...optionalParams: any[]): void;
685
+ info(): void;
661
686
  debug(message: any, ...optionalParams: any[]): void;
662
687
  trace(message: any, ...optionalParams: any[]): void;
663
- silent(message: any, ...optionalParams: any[]): void;
688
+ silent(): void;
664
689
  child(options: any): PinoWrapper;
665
690
  get level(): any;
666
691
  }
@@ -675,7 +700,6 @@ declare class ConfigServiceInstance<Config = Record<string, unknown>> implements
675
700
  getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
676
701
  }
677
702
 
678
- declare const ConfigProviderInjectionToken = "ConfigProvider";
679
703
  declare const ConfigProviderOptions: z.ZodObject<{
680
704
  load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
681
705
  }, "strip", z.ZodTypeAny, {
@@ -691,10 +715,10 @@ declare const ConfigProvider: InjectionToken<ConfigService<Record<string, unknow
691
715
  load: (...args: unknown[]) => unknown;
692
716
  }>>;
693
717
  declare class ConfigProviderFactory {
694
- logger: Promise<LoggerInstance>;
718
+ logger: LoggerInstance;
695
719
  create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
696
720
  }
697
- declare function makeConfigToken<Config extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigService<Config>>;
721
+ declare function provideConfig<ConfigMap extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigServiceInstance<ConfigMap>, undefined>;
698
722
 
699
723
  interface ControllerOptions {
700
724
  guards?: ClassType[] | Set<ClassType>;
@@ -708,6 +732,10 @@ declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends st
708
732
  config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
709
733
  }): (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>;
710
734
 
735
+ declare function Header(name: HttpHeader, value: string | number | string[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
736
+
737
+ declare function HttpCode(code: number): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
738
+
711
739
  interface ModuleOptions {
712
740
  controllers?: ClassType[] | Set<ClassType>;
713
741
  imports?: ClassType[] | Set<ClassType>;
@@ -716,9 +744,17 @@ interface ModuleOptions {
716
744
  declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
717
745
 
718
746
  declare const EndpointMetadataKey: unique symbol;
747
+ declare enum EndpointType {
748
+ Unknown = "unknown",
749
+ Config = "config",
750
+ Handler = "handler"
751
+ }
719
752
  interface EndpointMetadata {
720
753
  classMethod: string;
721
754
  url: string;
755
+ successStatusCode: number;
756
+ type: EndpointType;
757
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
722
758
  httpMethod: HttpMethod;
723
759
  config: BaseEndpointConfig | null;
724
760
  guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
@@ -779,6 +815,10 @@ declare class ControllerAdapterService {
779
815
  guardRunner: GuardRunnerService;
780
816
  private logger;
781
817
  setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
818
+ providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<undefined>) | undefined;
819
+ private provideSchemaForConfig;
820
+ private provideHandler;
821
+ private provideHandlerForConfig;
782
822
  }
783
823
 
784
824
  declare class ModuleLoaderService {
@@ -884,6 +924,7 @@ declare class NaviosApplication {
884
924
  setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): void;
885
925
  init(): Promise<void>;
886
926
  private getFastifyInstance;
927
+ private configureFastifyInstance;
887
928
  private initModules;
888
929
  enableCors(options: FastifyCorsOptions): void;
889
930
  setGlobalPrefix(prefix: string): void;
@@ -896,4 +937,4 @@ declare class NaviosFactory {
896
937
  private static registerLoggerConfiguration;
897
938
  }
898
939
 
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 };
940
+ export { Application, AttributeFactory, BadRequestException, BoundInjectionToken, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConfigProvider, ConfigProviderFactory, 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, FactoryInjectionToken, FactoryNotFound, FactoryTokenNotResolved, 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, normalizePath, override, provideConfig, provideServiceLocator, resolveService, setPromiseCollector, stripEndSlash, syncInject, yellow };
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';
@@ -162,12 +163,27 @@ declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObjec
162
163
  constructor(name: string | symbol | ClassType, schema: AnyZodObject | undefined);
163
164
  static create<T extends ClassType>(name: T): InjectionToken<InstanceType<T>, undefined>;
164
165
  static create<T extends ClassType, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: T, schema: Schema): InjectionToken<InstanceType<T>, Schema>;
165
- static create<T>(name: string): InjectionToken<T, undefined>;
166
- static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string, schema: Schema): InjectionToken<T, Schema>;
167
- toString(): string | symbol | ClassType;
168
- }
169
-
170
- declare function getInjectableToken<R, T extends ClassTypeWithInstance<R>>(target: ClassType): R extends {
166
+ static create<T>(name: string | symbol): InjectionToken<T, undefined>;
167
+ static create<T, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(name: string | any, schema: Schema): InjectionToken<T, Schema>;
168
+ static bound<T, S extends AnyZodObject | ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, value: z.input<S>): BoundInjectionToken<T, S>;
169
+ static factory<T, S extends AnyZodObject | ZodOptional<AnyZodObject>>(token: InjectionToken<T, S>, factory: () => Promise<z.input<S>>): FactoryInjectionToken<T, S>;
170
+ static refineType<T>(token: BoundInjectionToken<any, any>): BoundInjectionToken<T, any>;
171
+ }
172
+ declare class BoundInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, undefined> {
173
+ readonly token: InjectionToken<T, S>;
174
+ readonly value: z.input<S>;
175
+ constructor(token: InjectionToken<T, S>, value: z.input<S>);
176
+ }
177
+ declare class FactoryInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, S> {
178
+ readonly token: InjectionToken<T, S>;
179
+ readonly factory: () => Promise<z.input<S>>;
180
+ value?: z.input<S>;
181
+ resolved: boolean;
182
+ constructor(token: InjectionToken<T, S>, factory: () => Promise<z.input<S>>);
183
+ resolve(): Promise<z.input<S>>;
184
+ }
185
+
186
+ declare function getInjectableToken<R>(target: ClassType): R extends {
171
187
  create(...args: any[]): infer V;
172
188
  } ? InjectionToken<V> : InjectionToken<R>;
173
189
 
@@ -199,7 +215,8 @@ declare enum ErrorsEnum {
199
215
  InstanceNotFound = "InstanceNotFound",
200
216
  InstanceDestroying = "InstanceDestroying",
201
217
  UnknownError = "UnknownError",
202
- FactoryNotFound = "FactoryNotFound"
218
+ FactoryNotFound = "FactoryNotFound",
219
+ FactoryTokenNotResolved = "FactoryTokenNotResolved"
203
220
  }
204
221
 
205
222
  declare class FactoryNotFound extends Error {
@@ -208,6 +225,11 @@ declare class FactoryNotFound extends Error {
208
225
  constructor(name: string);
209
226
  }
210
227
 
228
+ declare class FactoryTokenNotResolved extends Error {
229
+ code: ErrorsEnum;
230
+ constructor(name: string | symbol | ClassType);
231
+ }
232
+
211
233
  declare class InstanceDestroying extends Error {
212
234
  name: string;
213
235
  code: ErrorsEnum;
@@ -290,6 +312,7 @@ declare class ServiceLocator {
290
312
  registerInstance<Instance>(token: InjectionToken<Instance, undefined>, instance: Instance): void;
291
313
  removeInstance<Instance>(token: InjectionToken<Instance, undefined>): Promise<any>;
292
314
  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;
315
+ private resolveTokenArgs;
293
316
  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
317
  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
318
  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>;
@@ -383,6 +406,8 @@ declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: Injec
383
406
  declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
384
407
  declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
385
408
 
409
+ declare function resolveService<T extends ClassType>(ctx: ServiceLocatorAbstractFactoryContext, target: T, args?: any[]): Promise<InstanceType<T>>;
410
+
386
411
  declare const clc: {
387
412
  bold: (text: string) => string;
388
413
  green: (text: string) => string;
@@ -657,10 +682,10 @@ declare class PinoWrapper {
657
682
  fatal(message: any, ...optionalParams: any[]): void;
658
683
  error(message: any, ...optionalParams: any[]): void;
659
684
  warn(message: any, ...optionalParams: any[]): void;
660
- info(message: any, ...optionalParams: any[]): void;
685
+ info(): void;
661
686
  debug(message: any, ...optionalParams: any[]): void;
662
687
  trace(message: any, ...optionalParams: any[]): void;
663
- silent(message: any, ...optionalParams: any[]): void;
688
+ silent(): void;
664
689
  child(options: any): PinoWrapper;
665
690
  get level(): any;
666
691
  }
@@ -675,7 +700,6 @@ declare class ConfigServiceInstance<Config = Record<string, unknown>> implements
675
700
  getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
676
701
  }
677
702
 
678
- declare const ConfigProviderInjectionToken = "ConfigProvider";
679
703
  declare const ConfigProviderOptions: z.ZodObject<{
680
704
  load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
681
705
  }, "strip", z.ZodTypeAny, {
@@ -691,10 +715,10 @@ declare const ConfigProvider: InjectionToken<ConfigService<Record<string, unknow
691
715
  load: (...args: unknown[]) => unknown;
692
716
  }>>;
693
717
  declare class ConfigProviderFactory {
694
- logger: Promise<LoggerInstance>;
718
+ logger: LoggerInstance;
695
719
  create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
696
720
  }
697
- declare function makeConfigToken<Config extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigService<Config>>;
721
+ declare function provideConfig<ConfigMap extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigServiceInstance<ConfigMap>, undefined>;
698
722
 
699
723
  interface ControllerOptions {
700
724
  guards?: ClassType[] | Set<ClassType>;
@@ -708,6 +732,10 @@ declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends st
708
732
  config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
709
733
  }): (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>;
710
734
 
735
+ declare function Header(name: HttpHeader, value: string | number | string[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
736
+
737
+ declare function HttpCode(code: number): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
738
+
711
739
  interface ModuleOptions {
712
740
  controllers?: ClassType[] | Set<ClassType>;
713
741
  imports?: ClassType[] | Set<ClassType>;
@@ -716,9 +744,17 @@ interface ModuleOptions {
716
744
  declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
717
745
 
718
746
  declare const EndpointMetadataKey: unique symbol;
747
+ declare enum EndpointType {
748
+ Unknown = "unknown",
749
+ Config = "config",
750
+ Handler = "handler"
751
+ }
719
752
  interface EndpointMetadata {
720
753
  classMethod: string;
721
754
  url: string;
755
+ successStatusCode: number;
756
+ type: EndpointType;
757
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
722
758
  httpMethod: HttpMethod;
723
759
  config: BaseEndpointConfig | null;
724
760
  guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
@@ -779,6 +815,10 @@ declare class ControllerAdapterService {
779
815
  guardRunner: GuardRunnerService;
780
816
  private logger;
781
817
  setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
818
+ providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<undefined>) | undefined;
819
+ private provideSchemaForConfig;
820
+ private provideHandler;
821
+ private provideHandlerForConfig;
782
822
  }
783
823
 
784
824
  declare class ModuleLoaderService {
@@ -884,6 +924,7 @@ declare class NaviosApplication {
884
924
  setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): void;
885
925
  init(): Promise<void>;
886
926
  private getFastifyInstance;
927
+ private configureFastifyInstance;
887
928
  private initModules;
888
929
  enableCors(options: FastifyCorsOptions): void;
889
930
  setGlobalPrefix(prefix: string): void;
@@ -896,4 +937,4 @@ declare class NaviosFactory {
896
937
  private static registerLoggerConfiguration;
897
938
  }
898
939
 
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 };
940
+ export { Application, AttributeFactory, BadRequestException, BoundInjectionToken, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConfigProvider, ConfigProviderFactory, 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, FactoryInjectionToken, FactoryNotFound, FactoryTokenNotResolved, 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, normalizePath, override, provideConfig, provideServiceLocator, resolveService, setPromiseCollector, stripEndSlash, syncInject, yellow };