import { Router } from 'express'; import type { Connection } from '@mathislair/mtbdb'; import type { ResolvedUserBinding } from './userResolver'; import type { CaseConvention } from './caseConvention'; import type { DaoCtor, HttpMethod, MiddlewareOrValidator, ResourceOptions, RouteSpec } from './types'; declare const ALL_METHODS: HttpMethod[]; /** * Fluent builder around an Express Router that mounts CRUD routes from mtbDB DAOs. * * ```ts * const api = new RestRouter(conn); * api.get('/user', UserDao); // GET /user → list * api.get('/user/:id', UserDao); // GET /user/:id → findById * api.post('/user', UserDao, auth); // POST /user with auth middleware * api.delete('/user/:id', UserDao, auth); * * app.use('/api', api.express()); * ``` */ export declare class RestRouter { readonly connection: Connection; private readonly _router; private readonly _routes; private _errorHandlerMounted; private _userBinding?; private _caseConvention?; private _paginate?; constructor(connection: Connection); /** Internal: bind a user resolver consumed by POST/PUT/PATCH handlers. */ _setUserBinding(binding: ResolvedUserBinding | undefined): void; /** Internal: configure the wire-format case convention for new routes. */ _setCaseConvention(c: CaseConvention | undefined): void; /** Internal: default for the per-route pagination envelope (can be overridden per resource). */ _setPaginate(on: boolean | undefined): void; /** Returns the underlying Express Router. Mount with `app.use(api.express())`. */ express(): Router; /** Snapshot of all registered routes (read-only view). */ routes(): readonly RouteSpec[]; get(path: string, dao: DaoCtor, ...mw: MiddlewareOrValidator[]): this; post(path: string, dao: DaoCtor, ...mw: MiddlewareOrValidator[]): this; put(path: string, dao: DaoCtor, ...mw: MiddlewareOrValidator[]): this; patch(path: string, dao: DaoCtor, ...mw: MiddlewareOrValidator[]): this; delete(path: string, dao: DaoCtor, ...mw: MiddlewareOrValidator[]): this; /** * Mount the conventional CRUD bundle (list, get-by-id, create, update, patch, delete) * for a single DAO under one base path. */ resource(basePath: string, dao: DaoCtor, opts?: ResourceOptions): this; /** * Mount a class previously decorated with @Path / @Get / @Post / etc. * Equivalent to calling each verb method in declaration order. */ register(controller: object | (new (...args: any[]) => unknown)): this; private _mount; } export interface ControllerMeta { basePath?: string; routes: { method: HttpMethod; path: string; dao: DaoCtor; middlewares: MiddlewareOrValidator[]; }[]; } export declare function getOrCreateControllerMeta(target: any): ControllerMeta; export declare function readControllerMeta(target: any): ControllerMeta | undefined; export { ALL_METHODS }; //# sourceMappingURL=RestRouter.d.ts.map