@sentzunhat/zacatl
Version:
A modular, high-performance TypeScript microservice framework for Node.js, featuring layered architecture, dependency injection, and robust validation for building scalable APIs and distributed systems.
32 lines • 1.69 kB
TypeScript
import type { FastifyReply, FastifySchema } from '../../../../../../../third-party/fastify.js';
import type { z } from '../../../../../../../third-party/zod.js';
import type { RouteHandler } from './route-handler';
import type { HTTPMethod } from '../../common/http-methods';
import type { Request } from '../../common/request';
export type { Request } from '../../common/request';
export interface RouteSchema<TBody = void, TQuerystring = void, TParams = void, THeaders = void, TResponse = void> {
body?: z.ZodType<TBody>;
querystring?: z.ZodType<TQuerystring>;
params?: z.ZodType<TParams>;
headers?: z.ZodType<THeaders>;
response?: z.ZodType<TResponse>;
}
export interface AbstractRouteHandlerConstructor {
url: string;
method: HTTPMethod;
schema: RouteSchema | FastifySchema | Record<string, unknown>;
}
export type HandlerOutput<TResponse> = TResponse;
export declare abstract class AbstractRouteHandler<TBody = void, TQuerystring = void, TResponse = void, TParams = void, THeaders = void> implements RouteHandler<TBody, TQuerystring, TResponse, TParams, THeaders> {
url: string;
method: HTTPMethod;
schema: RouteSchema | FastifySchema | Record<string, unknown>;
constructor(args: AbstractRouteHandlerConstructor);
abstract handler(request: Request<TBody, TQuerystring, TParams, THeaders>): Promise<HandlerOutput<TResponse>> | HandlerOutput<TResponse>;
protected handleError(error: Error): {
statusCode: number;
[key: string]: unknown;
};
execute(request: Request<TBody, TQuerystring, TParams, THeaders>, reply: FastifyReply): Promise<HandlerOutput<TResponse>>;
}
//# sourceMappingURL=abstract.d.ts.map