import { Processor, Middleware, Next, Meta } from 'rowan'; import { Context } from '../context'; import { MessageHeader } from '@viae/core'; export interface RouterOptions { /** route root path */ root?: string; /** route descriptive name */ name?: string; /** route documentation */ doc?: string; middleware?: Middleware[]; } export declare class Router implements Middleware, RouterOptions { /** route base path */ root: string; /** route descriptive name */ name: string; /** route documentation */ doc: string; /** route middleware */ middleware: Middleware[]; meta: Meta; private _rootMatch; constructor(opts?: RouterOptions); process(ctx: Context, next: Next): Promise; private use; route(opts: { path: string; method: string; process: Processor[]; name?: string; doc?: string; end?: boolean; }): void; } export interface HandlerOptions { data: any; head: MessageHeader; raw: Uint8Array; path: string; ctx: Context; params: Record; next?: Next; } export type ApiRouteOptions = { path: string; end?: true; next?: true; handler: (opt: HandlerOptions) => any; }; export type ApiFn = (opts: O) => void; export declare class Api implements Middleware { protected root?: string; private _router; constructor(root?: string); all: ApiFn; get: ApiFn; post: ApiFn; put: ApiFn; delete: ApiFn; subscribe: ApiFn; use(path: string, api: Middleware): void; process(ctx: Context, next: Next): Promise; }