|
@@ -0,0 +1,86 @@
|
|
1
|
+// Type definitions for serve-static 1.7.1
|
|
2
|
+// Project: https://github.com/expressjs/serve-static
|
|
3
|
+// Definitions by: Uros Smolnik <https://github.com/urossmolnik/>
|
|
4
|
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
5
|
+
|
|
6
|
+/* =================== USAGE ===================
|
|
7
|
+
|
|
8
|
+ import serveStatic = require('serve-static');
|
|
9
|
+ app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))
|
|
10
|
+
|
|
11
|
+ =============================================== */
|
|
12
|
+
|
|
13
|
+/// <reference path="../express/express.d.ts" />
|
|
14
|
+/// <reference path="../mime/mime.d.ts" />
|
|
15
|
+
|
|
16
|
+declare module "serve-static" {
|
|
17
|
+ import * as express from "express";
|
|
18
|
+
|
|
19
|
+ /**
|
|
20
|
+ * Create a new middleware function to serve files from within a given root directory.
|
|
21
|
+ * The file to serve will be determined by combining req.url with the provided root directory.
|
|
22
|
+ * When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs.
|
|
23
|
+ */
|
|
24
|
+ function serveStatic(root: string, options?: {
|
|
25
|
+ /**
|
|
26
|
+ * Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
|
|
27
|
+ * Note this check is done on the path itself without checking if the path actually exists on the disk.
|
|
28
|
+ * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
|
|
29
|
+ * The default value is 'ignore'.
|
|
30
|
+ * 'allow' No special treatment for dotfiles
|
|
31
|
+ * 'deny' Send a 403 for any request for a dotfile
|
|
32
|
+ * 'ignore' Pretend like the dotfile does not exist and call next()
|
|
33
|
+ */
|
|
34
|
+ dotfiles?: string;
|
|
35
|
+
|
|
36
|
+ /**
|
|
37
|
+ * Enable or disable etag generation, defaults to true.
|
|
38
|
+ */
|
|
39
|
+ etag?: boolean;
|
|
40
|
+
|
|
41
|
+ /**
|
|
42
|
+ * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
|
|
43
|
+ * The first that exists will be served. Example: ['html', 'htm'].
|
|
44
|
+ * The default value is false.
|
|
45
|
+ */
|
|
46
|
+ extensions?: string[];
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * By default this module will send "index.html" files in response to a request on a directory.
|
|
50
|
+ * To disable this set false or to supply a new index pass a string or an array in preferred order.
|
|
51
|
+ */
|
|
52
|
+ index?: boolean;
|
|
53
|
+
|
|
54
|
+ /**
|
|
55
|
+ * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
|
|
56
|
+ */
|
|
57
|
+ lastModified?: boolean;
|
|
58
|
+
|
|
59
|
+ /**
|
|
60
|
+ * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
|
|
61
|
+ */
|
|
62
|
+ maxAge?: number;
|
|
63
|
+
|
|
64
|
+ /**
|
|
65
|
+ * Redirect to trailing "/" when the pathname is a dir. Defaults to true.
|
|
66
|
+ */
|
|
67
|
+ redirect?: boolean;
|
|
68
|
+
|
|
69
|
+ /**
|
|
70
|
+ * Function to set custom headers on response. Alterations to the headers need to occur synchronously.
|
|
71
|
+ * The function is called as fn(res, path, stat), where the arguments are:
|
|
72
|
+ * res the response object
|
|
73
|
+ * path the file path that is being sent
|
|
74
|
+ * stat the stat object of the file that is being sent
|
|
75
|
+ */
|
|
76
|
+ setHeaders?: (res: express.Response, path: string, stat: any) => any;
|
|
77
|
+ }): express.Handler;
|
|
78
|
+
|
|
79
|
+ import * as m from "mime";
|
|
80
|
+
|
|
81
|
+ module serveStatic {
|
|
82
|
+ var mime: typeof m;
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ export = serveStatic;
|
|
86
|
+}
|