import type { Express, Request, Response } from 'express'; import { z } from 'zod'; import type { API, ZodBase } from '../def'; /** * Arguments passed to an Express handler for an API endpoint. */ export interface HandlerArgs { /** The Express request object. */ request: Request; /** The Express response object. */ response: Response; /** The parsed and validated Data Transfer Object (DTO) from the request body. */ dto: DTO extends ZodBase ? z.output : void; } /** * The expected result from an API handler, which is a Promise resolving to the Value Object (VO) or void. */ export type HandlerResult = VO extends ZodBase ? Promise> : Promise; /** * A handler function that implements the logic for an API endpoint. * @param args The handler arguments, including request, response, and DTO. * @returns A Promise that resolves with the response data (VO) or void. */ export interface Handler { (args: HandlerArgs): HandlerResult; } /** * Implements a type-safe API endpoint on an Express instance. * @param express The Express application instance. * @param api The API definition created by `defineAPI`. * @param handler The handler function that implements the API logic. * @param onError An optional callback for handling errors. */ export declare function implApi(express: Express, api: API, handler: Handler, onError?: (err: Error) => void): void; /** * Implements a type-safe API endpoint on an Express instance using a configuration object. * @param impl An object containing the Express instance, API definition, handler, and optional error callback. */ export declare function implApi(impl: { express: Express; api: API; handler: Handler; onError?: (err: Error) => void; }): void; //# sourceMappingURL=express.d.ts.map