import { Request as ExpressRequest, Response as ExpressResponse, NextFunction as ExpressNextFunction } from 'express' import { IncomingHttpHeaders } from 'http' import { SchemaObject } from 'openapi3-ts' import { z } from 'zod' import { PathVariables } from './parse-path' export type ZodTypeWithMeta = z.ZodType & { metaOpenApi?: SchemaObject | SchemaObject[] } export type ZodHeaderValue = z.ZodString | z.ZodOptional export type HeadersAnySchema = Record export type ParsedHeaders = { [K in keyof H]: z.infer } export type ExpressoRequest

, Res, Req, H extends HeadersAnySchema> = ExpressRequest< P, Res, Req > & { headers?: IncomingHttpHeaders & ParsedHeaders } export type HTTPMethod = 'get' | 'put' | 'post' | 'delete' export type EndpointProps = { path: Path input?: I output?: O headers?: H operationId?: string deprecated?: boolean } export type EndpointHandler< Path extends string, I extends z.ZodType, O extends z.ZodType, H extends HeadersAnySchema > = ( req: ExpressoRequest, z.infer, z.infer, H>, res: ExpressResponse>, next: ExpressNextFunction ) => Promise export type Endpoint< Path extends string, I extends ZodTypeWithMeta, O extends ZodTypeWithMeta, H extends HeadersAnySchema, M extends HTTPMethod > = EndpointProps & { method: M; handler: EndpointHandler } export type AnyEndpoint = Endpoint