You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create a new middleware function to serve files from within a given root directory.
20
+
* The file to serve will be determined by combining req.url with the provided root directory.
21
+
* 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.
22
+
*/
23
+
functionserveStatic(root: string,options?: {
24
+
/**
25
+
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
26
+
* Note this check is done on the path itself without checking if the path actually exists on the disk.
27
+
* 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").
28
+
* The default value is 'ignore'.
29
+
* 'allow' No special treatment for dotfiles
30
+
* 'deny' Send a 403 for any request for a dotfile
31
+
* 'ignore' Pretend like the dotfile does not exist and call next()
32
+
*/
33
+
dotfiles?: string;
34
+
35
+
/**
36
+
* Enable or disable etag generation, defaults to true.
37
+
*/
38
+
etag?: boolean;
39
+
40
+
/**
41
+
* 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.
42
+
* The first that exists will be served. Example: ['html', 'htm'].
43
+
* The default value is false.
44
+
*/
45
+
extensions?: boolean;
46
+
47
+
/**
48
+
* By default this module will send "index.html" files in response to a request on a directory.
49
+
* To disable this set false or to supply a new index pass a string or an array in preferred order.
50
+
*/
51
+
index?: boolean;
52
+
53
+
/**
54
+
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
55
+
*/
56
+
lastModified?: boolean;
57
+
58
+
/**
59
+
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
60
+
*/
61
+
maxAge?: number;
62
+
63
+
/**
64
+
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
65
+
*/
66
+
redirect?: number;
67
+
68
+
/**
69
+
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
70
+
* The function is called as fn(res, path, stat), where the arguments are:
71
+
* res the response object
72
+
* path the file path that is being sent
73
+
* stat the stat object of the file that is being sent
0 commit comments