import { IncomingHttpEvent } from '../IncomingHttpEvent.js'; import { OutgoingHttpResponse } from '../OutgoingHttpResponse.js'; import { NextMiddleware, MetaMiddleware } from '@stone-js/core'; /** * Build the response a route declared, from whatever its handler returned. * * A route already says what it is: its path, its method, what it accepts, what it answers with. Saying * the last part on the route rather than on the method keeps the handler about the domain, and keeps one * place to read when you want to know what an endpoint returns. * * ```ts * @Get('/tasks/:id', { response: { type: 'json', status: 200 } }) * show (event: IncomingHttpEvent): Task { return this.tasks.find(event.get('id')) } * ``` * * A method decorator still wins. `@JsonHttpResponse(201)` produces the response itself, and something * more specific than a route option must not be overruled by it: when the handler has already answered * with a response, this steps aside entirely. The two forms are a choice, not a conflict. */ export declare class RouteResponseMiddleware { /** * @param event - The incoming event. * @param next - The next middleware. * @returns The outgoing response. */ handle(event: IncomingHttpEvent, next: NextMiddleware): Promise; /** * Whether the handler already answered with a response of its own. * * @param value - What the handler returned. * @returns True when it is already a response. */ private isResponse; /** * Build the declared response around a payload. * * @param content - What the handler returned. * @param declared - What the route said it answers with. * @returns The response. */ private build; } /** * Meta middleware for a route's declared response. * * On `stone.router.middleware`, outside every other route middleware: it builds the final response, so * it must see the payload after a resource has shaped it and after a guard has had its say. */ export declare const MetaRouteResponseMiddleware: MetaMiddleware;