import { CommandContext } from "./command.js"; import { HttpRequest, HttpResponse } from "./request-response.js"; export interface MiddlewareInput { request: HttpRequest; context: In; next: (context: O) => Promise>; } export interface MiddlewareOutput extends HttpResponse { context?: Context; } export type Middleware = (input: MiddlewareInput) => Promise> | MiddlewareOutput; /** * Utility for creating a Middleware function that combines its output context * with the input context. * * ```ts * const auth = middleware(({request, next}) => { * return next({ * isAuthenticated: request.headers.Authorization !== undefined * }) * }); * * api.use(auth).command("myAuthorizedCommand", async (request, { isAuthenticated }) => { * if (isAuthenticated) { * // do work * } * }) * ``` * * @param fn * @returns */ export declare function middleware(fn: Middleware): (input: MiddlewareInput) => Promise>; //# sourceMappingURL=middleware.d.ts.map