import type { Request, Response, RequestHandler } from 'express'; import type { AbstractBean, AbstractDao, Connection, BeanCtor } from '@mathislair/mtbdb'; export type DaoCtor = new (conn: Connection) => AbstractDao; export type BeanCtorAny = BeanCtor; /** Express middleware: (req, res, next). */ export type Middleware = RequestHandler; /** * Validator: a short function called before the CRUD handler runs. * - May throw an HttpError (or any Error) to short-circuit the request. * - May return an HttpError to short-circuit the request. * - May return a Promise of either of the above. */ export type Validator = (req: Request, res: Response) => void | Error | Promise; export type MiddlewareOrValidator = Middleware | Validator; export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; /** Internal route record kept by the router and the decorator metadata. */ export interface RouteSpec { method: HttpMethod; path: string; dao: DaoCtor; middlewares: MiddlewareOrValidator[]; } export interface ResourceOptions { /** Path param name to use for item routes. Default: "id". */ idParam?: string; /** Middlewares applied to every route on the resource. */ middlewares?: MiddlewareOrValidator[]; /** Per-verb middlewares appended after the global ones. */ perMethod?: Partial>; /** Disable specific verbs. By default all of get/getOne/post/put/patch/delete are mounted. */ except?: HttpMethod[]; /** * If true, list responses on this resource are wrapped in a paginated * envelope: `{ data, total, limit, offset }`. Adds an extra count(*) * query per request. Overrides the facade-level default. */ paginate?: boolean; } //# sourceMappingURL=types.d.ts.map