UNPKG

@kadena/hardhat-chainweb

Version:
37 lines 1.26 kB
export interface RouteNext<T> { success: (msg: string, mimeType: string) => void; failure: (msg: string, code: number) => void; proxy: (handler: T) => void; } type PromiseOrValue<T> = T | Promise<T>; interface SuccessResult { type: 'success'; result: { msg: string; mimeType: string; }; } interface FailureResult { type: 'failure'; error: { msg: string; code: number; }; } interface ProxyResult<T> { type: 'proxy'; handler: T; } export interface RouteReturn<T> { success: (msg: string, mimeType: string) => SuccessResult; failure: (msg: string, code: number) => FailureResult; proxy: (handler: T) => ProxyResult<T>; } type HandlerType<CTX, PROXY_ARG> = (params: Record<string, string>, next: RouteReturn<PROXY_ARG>, context: CTX) => PromiseOrValue<SuccessResult | FailureResult | ProxyResult<PROXY_ARG>>; export declare class Router<CTX, PROXY_ARG> { private routes; route(route: string, handler: HandlerType<CTX, PROXY_ARG>, validate?: (params: Record<string, undefined | string | string[]>) => boolean): void; execute(url: string | undefined, next: RouteNext<PROXY_ARG>, context: CTX, tag: string): Promise<void>; } export {}; //# sourceMappingURL=Route.d.ts.map