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

87 lines 2.19 kB
import { FastifyInstance, FastifyRequest, FastifyReply } from "fastify"; import { z } from "zod"; export interface RouteDefinition { method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"; path: string; handler: (request: FastifyRequest, reply: FastifyReply) => Promise<any> | any; schema?: { body?: z.ZodSchema; querystring?: z.ZodSchema; params?: z.ZodSchema; headers?: z.ZodSchema; response?: Record<number, z.ZodSchema>; }; preHandler?: any[]; config?: any; summary?: string; description?: string; tags?: string[]; } export interface FileRouterOptions { routesDir: string; baseUrl?: string; watchMode?: boolean; ignorePaths?: string[]; enableHotReload?: boolean; } export declare class FileBasedRouter { private app; private options; private routes; private watcher?; private registeredRoutes; constructor(app: FastifyInstance, options: FileRouterOptions); /** * Initialize the file-based router */ initialize(): Promise<void>; /** * Scan for route files */ private scanRoutes; /** * Load a single route file */ private loadRoute; /** * Parse route definition from file path and module */ private parseRouteFromFile; /** * Register routes with Fastify */ private registerRoutes; /** * Convert Zod schemas to Fastify JSON schemas */ private convertZodToFastifySchema; /** * Convert Zod schema to JSON schema (simplified) */ private zodToJsonSchema; /** * Start watching for file changes */ private startWatching; /** * Handle file changes (hot reload) */ private handleFileChange; /** * Handle file removal */ private handleFileRemoval; /** * Get all registered routes */ getRoutes(): RouteDefinition[]; /** * Get route by method and path */ getRoute(method: string, path: string): RouteDefinition | undefined; /** * Stop watching and cleanup */ stop(): Promise<void>; } //# sourceMappingURL=file-router.d.ts.map