1 | // Type definitions for koa-send 4.1
|
2 | // Project: https://github.com/koajs/send
|
3 | // Definitions by: Peter Safranek <https://github.com/pe8ter>
|
4 | // Tomek Łaziuk <https://github.com/tlaziuk>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 | // TypeScript Version: 2.3
|
7 |
|
8 | import {
|
9 | ParameterizedContext,
|
10 | } from "koa";
|
11 |
|
12 | import {
|
13 | Stats,
|
14 | } from "fs";
|
15 |
|
16 | declare function send(ctx: ParameterizedContext, path: string, opts?: send.SendOptions): Promise<string>;
|
17 |
|
18 | declare namespace send {
|
19 | type SetHeaders = (res: ParameterizedContext["res"], path: string, stats: Stats) => any;
|
20 |
|
21 | interface SendOptions {
|
22 | /** Browser cache max-age in milliseconds. (defaults to 0) */
|
23 | maxage?: number | undefined;
|
24 | maxAge?: SendOptions["maxage"] | undefined;
|
25 | /** Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false) */
|
26 | immutable?: boolean | undefined;
|
27 | /** Allow transfer of hidden files. (defaults to false) */
|
28 | hidden?: boolean | undefined;
|
29 | /** Root directory to restrict file access. (defaults to '') */
|
30 | root?: string | undefined;
|
31 | /** Name of the index file to serve automatically when visiting the root location. (defaults to none) */
|
32 | index?: string | false | undefined;
|
33 | /** Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. (defaults to true). */
|
34 | gzip?: boolean | undefined;
|
35 | /** Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. (defaults to true). */
|
36 | brotli?: boolean | undefined;
|
37 | /** If not false (defaults to true), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/. */
|
38 | format?: boolean | undefined;
|
39 | /** Function to set custom headers on response. */
|
40 | setHeaders?: SetHeaders | undefined;
|
41 | /** Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false) */
|
42 | extensions?: string[] | false | undefined;
|
43 | }
|
44 | }
|
45 |
|
46 | export = send;
|