UNPKG

@athenna/http

Version:

The Athenna Http server. Built on top of fastify.

40 lines (39 loc) 1.61 kB
/** * @athenna/http * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { RequestHandler } from '#src/types/contexts/Context'; import type { ErrorHandler } from '#src/types/contexts/ErrorContext'; import type { InterceptHandler, TerminateHandler } from '#src/types'; import type { FastifyReply, FastifyRequest, RouteHandlerMethod } from 'fastify'; export declare class FastifyHandler { /** * Parse the fastify request handler and the preHandler hook to an Athenna * request handler. */ static request(handler: RequestHandler): RouteHandlerMethod; /** * Just and alises for the request handler. */ static handle(handler: RequestHandler): RouteHandlerMethod; /** * Parse the fastify onSend hook to an Athenna intercept handler. */ static intercept(handler: InterceptHandler): (req: FastifyRequest, res: FastifyReply, payload: any) => Promise<any>; /** * Parse the fastify onResponse hook to an Athenna terminate handler. */ static terminate(handler: TerminateHandler): (req: FastifyRequest, res: FastifyReply) => Promise<void>; /** * Parse the fastify onError hook to an Athenna error handler. */ static error(handler: ErrorHandler): (error: any, req: FastifyRequest, res: FastifyReply) => Promise<void>; /** * Parse the fastify not found route handler. */ static notFoundError(handler: ErrorHandler): (req: FastifyRequest, res: FastifyReply) => Promise<void>; }