UNPKG

1.25 kBTypeScriptView Raw
1// Type definitions for connect-history-api-fallback 1.5
2// Project: https://github.com/bripkens/connect-history-api-fallback#readme
3// Definitions by: Douglas Duteil <https://github.com/douglasduteil>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.3
6
7/// <reference types="node" />
8
9import { Url } from 'url';
10
11import * as core from "express-serve-static-core";
12
13export = historyApiFallback;
14
15declare function historyApiFallback(options?: historyApiFallback.Options): core.RequestHandler;
16
17declare namespace historyApiFallback {
18 interface Options {
19 readonly disableDotRule?: true | undefined;
20 readonly htmlAcceptHeaders?: ReadonlyArray<string> | undefined;
21 readonly index?: string | undefined;
22 readonly logger?: typeof console.log | undefined;
23 readonly rewrites?: ReadonlyArray<Rewrite> | undefined;
24 readonly verbose?: boolean | undefined;
25 }
26
27 interface Context {
28 readonly match: RegExpMatchArray;
29 readonly parsedUrl: Url;
30 readonly request: core.Request;
31 }
32 type RewriteTo = (context: Context) => string;
33
34 interface Rewrite {
35 readonly from: RegExp;
36 readonly to: string | RegExp | RewriteTo;
37 }
38}