import type { FastifyRequest, FastifyReply } from 'fastify'; import type { InjectFn, TokenObject } from '@pylonts/core'; declare module 'fastify' { interface FastifyRequest { /** Flat token object restored by the auth chain (Redis {app}.{token}). */ token?: TokenObject; } } export type RouteHandler = (request: FastifyRequest, reply: FastifyReply) => R | FastifyReply | Promise | void; export interface HandlerMeta { /** Route belongs to an RPC controller */ isRpc: boolean; /** Route has @File decorator */ isFile: boolean; /** Route has @Stream decorator */ isStream: boolean; /** Server-inject adapters collected from the body DTO (__inject on base schemas) */ inject?: InjectFn[]; } export interface HandlerFactory { /** Returns true if this factory can handle the given route metadata */ accept(meta: HandlerMeta): boolean; /** Creates a Fastify route handler — call style is baked in at creation time */ create(boundHandler: (...args: unknown[]) => Promise, meta: HandlerMeta): RouteHandler; } /** Sends file from disk with Content-Disposition header */ export declare class FileHandlerFactory implements HandlerFactory { accept(meta: HandlerMeta): boolean; create(boundHandler: (...args: unknown[]) => Promise, meta: HandlerMeta): RouteHandler; } /** Sends content with Content-Disposition header for streaming */ export declare class StreamHandlerFactory implements HandlerFactory { accept(meta: HandlerMeta): boolean; create(boundHandler: (...args: unknown[]) => Promise, meta: HandlerMeta): RouteHandler; } /** RPC-style controller handler: extracts (body, user) from the request */ export declare class RpcHandlerFactory implements HandlerFactory { accept(meta: HandlerMeta): boolean; create(boundHandler: (...args: unknown[]) => Promise, meta: HandlerMeta): RouteHandler; } /** Default handler: passes request & reply, returns result as-is */ export declare class DefaultHandlerFactory implements HandlerFactory { accept(meta: HandlerMeta): boolean; create(boundHandler: (...args: unknown[]) => unknown, _meta: HandlerMeta): RouteHandler; } /** Registry that holds HandlerFactory instances and delegates via first-match */ export declare class HandlerFactoryRegistry { private factories; register(factory: HandlerFactory): void; create(boundHandler: (...args: unknown[]) => Promise, meta: HandlerMeta): RouteHandler; } //# sourceMappingURL=handler-factory.d.ts.map