UNPKG

@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.

34 lines 1.66 kB
import type { Request as ExpressRequest, Response } from 'express'; import type { z } from '../../../../../../../third-party/zod.js'; import type { HTTPMethod } from '../../common/http-methods'; 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 | Record<string, unknown>; } export type HandlerOutput<TResponse> = TResponse; export declare abstract class AbstractRouteHandler<TBody = void, TQuerystring = void, TResponse = void, TParams = void, THeaders = void> { url: string; method: HTTPMethod; schema: RouteSchema | Record<string, unknown>; protected readonly _phantomBody?: TBody; protected readonly _phantomQuerystring?: TQuerystring; protected readonly _phantomParams?: TParams; protected readonly _phantomHeaders?: THeaders; constructor(args: AbstractRouteHandlerConstructor); abstract handler(request: ExpressRequest<TParams, TResponse, TBody, TQuerystring>): Promise<HandlerOutput<TResponse>> | HandlerOutput<TResponse>; protected handleError(error: Error): { statusCode: number; [key: string]: unknown; }; execute(request: ExpressRequest<TParams, TResponse, TBody, TQuerystring>, reply: Response): Promise<HandlerOutput<TResponse>>; } //# sourceMappingURL=abstract.d.ts.map