UNPKG

@pulzar/core

Version:

Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support

52 lines 1.99 kB
import type { FastifyRequest, FastifyInstance } from "fastify"; import { FastContainer } from "./zero-reflection"; import { Token } from "./tokens"; declare module "fastify" { interface FastifyRequest { container: FastContainer; } } export interface FastifyDIOptions { container: FastContainer; generateRequestId?: () => string; onRequestStart?: (request: FastifyRequest, container: FastContainer) => void; onRequestEnd?: (request: FastifyRequest, container: FastContainer) => void; } /** * Fastify plugin for request-scoped DI containers */ export declare function fastifyDI(fastify: FastifyInstance, options: FastifyDIOptions): Promise<void>; /** * Helper decorator for request-scoped services */ export declare function RequestScoped(): ClassDecorator; /** * Helper decorator for injecting request-scoped services */ export declare function InjectRequest<T>(token: Token<T>): (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Utility to get container from request */ export declare function getRequestContainer(request: FastifyRequest): FastContainer; /** * Utility to resolve service from request */ export declare function resolveFromRequest<T>(request: FastifyRequest, token: Token<T>): T; /** * Route handler decorator that automatically injects dependencies */ export declare function Route(options: { method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; path: string; inject?: Token[]; }): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Controller decorator for class-based route handling */ export declare function Controller(prefix?: string): (target: any) => any; /** * Register controller with Fastify instance */ export declare function registerController(fastify: FastifyInstance, ControllerClass: any, container: FastContainer): void; export default fastifyDI; //# sourceMappingURL=fastify-integration.d.ts.map