1 | /// <reference types="express" />
|
2 | import { Request } from '../types';
|
3 | import { ResolvedRoute, RouteEntry } from './route-entry';
|
4 | export interface RestRouter {
|
5 | /**
|
6 | * Add a route to the router
|
7 | * @param route - A route entry
|
8 | */
|
9 | add(route: RouteEntry): void;
|
10 | /**
|
11 | * Find a matching route for the given http request
|
12 | * @param request - Http request
|
13 | * @returns The resolved route, if not found, `undefined` is returned
|
14 | */
|
15 | find(request: Request): ResolvedRoute | undefined;
|
16 | /**
|
17 | * List all routes
|
18 | */
|
19 | list(): RouteEntry[];
|
20 | }
|
21 | export type RestRouterOptions = {
|
22 | /**
|
23 | * When `true` it uses trailing slash to match. (default: `false`)
|
24 | *
|
25 | * 1. `strict` is true:
|
26 | * - request `/orders` matches route `/orders` but not `/orders/`
|
27 | * - request `/orders/` matches route `/orders/` but not `/orders`
|
28 | *
|
29 | * 2. `strict` is false (default)
|
30 | * - request `/orders` matches route `/orders` first and falls back to `/orders/`
|
31 | * - request `/orders/` matches route `/orders/` first and falls back to `/orders`
|
32 | *
|
33 | * See `strict routing` at http://expressjs.com/en/4x/api.html#app
|
34 | */
|
35 | strict?: boolean;
|
36 | };
|