@lcap/builder
Version:
lcap builder utils
23 lines (22 loc) • 841 B
TypeScript
import type { IncomingMessage, ServerResponse } from 'http';
import { LcapBuildOptions } from '../build/types';
type Method = 'GET' | 'OPTIONS' | 'POST' | 'PUT' | 'DELETE';
export interface Request {
url: string;
method: Method;
query: Record<string, string>;
data: any;
context: LcapBuildOptions;
}
export interface APIRouterOptions {
url: string;
method: Method;
handler: (req: Request) => Promise<any>;
}
export declare const createAPIHandler: (url: string, method: APIRouterOptions["method"], handler: APIRouterOptions["handler"]) => {
url: string;
method: Method;
handler: (req: Request) => Promise<any>;
};
export declare const createAPIMiddleware: (routes: APIRouterOptions[], context: LcapBuildOptions) => (req: IncomingMessage, res: ServerResponse, next: any) => Promise<any>;
export {};