UNPKG

845 BTypeScriptView Raw
1/** @format */
2import { Middleware, MiddlewareObj } from './middleware';
3import Context from './context';
4declare type NonemptyReadonlyArray<T> = readonly [T, ...T[]];
5declare type RouteFn<TContext extends Context> = (ctx: TContext) => {
6 route: string;
7 context?: Partial<TContext>;
8 state?: Partial<TContext['state']>;
9} | null;
10export declare class Router<C extends Context> implements MiddlewareObj<C> {
11 private readonly routeFn;
12 handlers: Map<string, Middleware<C>>;
13 private otherwiseHandler;
14 constructor(routeFn: RouteFn<C>, handlers?: Map<string, Middleware<C>>);
15 on(route: string, ...fns: NonemptyReadonlyArray<Middleware<C>>): this;
16 otherwise(...fns: NonemptyReadonlyArray<Middleware<C>>): this;
17 middleware(): import("./middleware").MiddlewareFn<C>;
18}
19export {};
20//# sourceMappingURL=router.d.ts.map
\No newline at end of file