import type openapi from "openapi3-ts"; import type { FunctionRuntimeProps } from "../function-props.js"; import type { HttpMethod } from "../http-method.js"; import type { SourceLocation } from "../internal/service-spec.js"; import { Command, CommandContext, CommandHandler, CommandOptions, CommandOutputOptions } from "./command.js"; import type { MiddlewareInput, MiddlewareOutput } from "./middleware.js"; import type { HttpRequest, HttpResponse } from "./request-response.js"; /** * This Proxy intercepts the method being called, e.g. `get`, `post`, etc. * and includes that information in the created {@link HttpRoute} object. This * information is then picked up during infer so we know the HTTP method * for each route. * * It also includes `sourceLocation` (injected by the compiler), `path`, and * any `runtimeProps` passed in by the user. * * @see HttpRoute for all the metadata associated with each route */ export declare const api: HttpRouter; export type RouteRuntimeProps = FunctionRuntimeProps; export interface ApiRouteProps extends RouteRuntimeProps { /** * Description of the route. * * Used to generate the {@link ApiSpecification}. */ description?: string; /** * Outputs of the route. * * Used to generate the {@link ApiSpecification}. */ outputs?: CommandOutputOptions[]; } export type HttpHandler = (request: HttpRequest, context: Context) => HttpResponse | Promise; export interface HttpRoute { path: string; handlers: HttpHandler[]; method: HttpMethod; props?: ApiRouteProps; /** * Only available during eventual-infer */ sourceLocation?: SourceLocation; } export interface HttpRouteFactory { (path: string, props: ApiRouteProps, handlers: HttpHandler): HttpRouter; (path: string, handlers: HttpHandler): HttpRouter; } export interface HttpRouter { handle: (request: HttpRequest, ...extra: any) => Promise; routes: HttpRouteEntry[]; all: HttpRouteFactory; get: HttpRouteFactory; head: HttpRouteFactory; post: HttpRouteFactory; put: HttpRouteFactory; delete: HttpRouteFactory; connect: HttpRouteFactory; options: HttpRouteFactory; trace: HttpRouteFactory; patch: HttpRouteFactory; use(middleware: (input: MiddlewareInput) => Promise> | MiddlewareOutput): HttpRouter; command(name: Name, handler: CommandHandler): Command; command(name: Name, options: CommandOptions, handler: CommandHandler): Command; } export type HttpRouteEntry = [string, RegExp, HttpHandler]; export interface ApiSpecification { generate: (options?: { includeRpcPaths?: boolean; }) => openapi.OpenAPIObject; } export declare const ApiSpecification: ApiSpecification; //# sourceMappingURL=api.d.ts.map