UNPKG

@lcap/builder

Version:
24 lines (23 loc) 872 B
/// <reference types="node" /> 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 {};