@pkg-nec/http-server 14.1.1-pkgnec.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2022 Charlie Robbins, Marak Squires, Jade Michael Thornton and the Contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ [![GitHub Workflow Status (trunk)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=trunk&style=flat-square)](https://github.com/pkg-nec/http-server/actions)
2
+ [![npm](https://img.shields.io/npm/v/@pkg-nec/http-server.svg?style=flat-square)](https://www.npmjs.com/package/@pkg-nec/http-server) [![npm downloads](https://img.shields.io/npm/dm/@pkg-nec/http-server?color=blue&label=npm%20downloads&style=flat-square)](https://www.npmjs.com/package/@pkg-nec/http-server)
3
+ [![license](https://img.shields.io/github/license/pkg-nec/http-server.svg?style=flat-square)](https://github.com/pkg-nec/http-server)
4
+
5
+ > **Maintained fork.** This is `@pkg-nec/http-server`, a maintained fork of [`http-party/http-server`](https://github.com/http-party/http-server), which has been effectively unmaintained since early 2022. This fork ships vulnerability patches only — no new features. Report issues at [pkg-nec/http-server/issues](https://github.com/pkg-nec/http-server/issues).
6
+
7
+ # http-server: a simple static HTTP server
8
+
9
+ `http-server` is a simple, zero-configuration command-line static HTTP server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development and learning.
10
+
11
+ ![Example of running http-server](https://github.com/pkg-nec/http-server/raw/trunk/screenshots/public.png)
12
+
13
+ ## Installation:
14
+
15
+ #### Running on-demand:
16
+
17
+ Using `npx` you can run the script without installing it first:
18
+
19
+ npx @pkg-nec/http-server [path] [options]
20
+
21
+ #### Globally via `npm`
22
+
23
+ npm install --global @pkg-nec/http-server
24
+
25
+ This will install `http-server` globally so that it may be run from the command line anywhere.
26
+
27
+ #### As a dependency in your `npm` package:
28
+
29
+ npm install @pkg-nec/http-server
30
+
31
+ ## Usage:
32
+
33
+ http-server [path] [options]
34
+
35
+ `[path]` defaults to `./public` if the folder exists, and `./` otherwise.
36
+
37
+ *Now you can visit http://localhost:8080 to view your server*
38
+
39
+ **Note:** Caching is on by default. Add `-c-1` as an option to disable caching.
40
+
41
+ ## Available Options:
42
+
43
+ | Command | Description | Defaults |
44
+ | ------------- |-------------|-------------|
45
+ |`-p` or `--port` |Port to use. Use `-p 0` to look for an open port, starting at 8080. It will also read from `process.env.PORT`. |8080 |
46
+ |`-a` |Address to use |0.0.0.0|
47
+ |`-d` |Show directory listings |`true` |
48
+ |`-i` | Display autoIndex | `true` |
49
+ |`-g` or `--gzip` |When enabled it will serve `./public/some-file.js.gz` in place of `./public/some-file.js` when a gzipped version of the file exists and the request accepts gzip encoding. If brotli is also enabled, it will try to serve brotli first.|`false`|
50
+ |`-b` or `--brotli`|When enabled it will serve `./public/some-file.js.br` in place of `./public/some-file.js` when a brotli compressed version of the file exists and the request accepts `br` encoding. If gzip is also enabled, it will try to serve brotli first. |`false`|
51
+ |`-e` or `--ext` |Default file extension if none supplied |`html` |
52
+ |`-s` or `--silent` |Suppress log messages from output | |
53
+ |`--cors` |Enable CORS via the `Access-Control-Allow-Origin` header | |
54
+ |`-o [path]` |Open browser window after starting the server. Optionally provide a URL path to open. e.g.: -o /other/dir/ | |
55
+ |`-c` |Set cache time (in seconds) for cache-control max-age header, e.g. `-c10` for 10 seconds. To disable caching, use `-c-1`.|`3600` |
56
+ |`-U` or `--utc` |Use UTC time format in log messages.| |
57
+ |`--log-ip` |Enable logging of the client's IP address |`false` |
58
+ |`-P` or `--proxy` |Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com | |
59
+ |`--proxy-options` |Pass proxy [options](https://github.com/http-party/node-http-proxy#options) using nested dotted objects. e.g.: --proxy-options.secure false |
60
+ |`--username` |Username for basic authentication | |
61
+ |`--password` |Password for basic authentication | |
62
+ |`-S`, `--tls` or `--ssl` |Enable secure request serving with TLS/SSL (HTTPS)|`false`|
63
+ |`-C` or `--cert` |Path to ssl cert file |`cert.pem` |
64
+ |`-K` or `--key` |Path to ssl key file |`key.pem` |
65
+ |`-r` or `--robots` | Automatically provide a /robots.txt (The content of which defaults to `User-agent: *\nDisallow: /`) | `false` |
66
+ |`--no-dotfiles` |Do not show dotfiles| |
67
+ |`--mimetypes` |Path to a .types file for custom mimetype definition| |
68
+ |`-h` or `--help` |Print this list and exit. | |
69
+ |`-v` or `--version`|Print the version and exit. | |
70
+
71
+ ## Magic Files
72
+
73
+ - `index.html` will be served as the default file to any directory requests.
74
+ - `404.html` will be served if a file is not found. This can be used for Single-Page App (SPA) hosting to serve the entry page.
75
+
76
+ ## Catch-all redirect
77
+
78
+ To implement a catch-all redirect, use the index page itself as the proxy with:
79
+
80
+ ```
81
+ http-server --proxy http://localhost:8080?
82
+ ```
83
+
84
+ Note the `?` at the end of the proxy URL. Thanks to [@houston3](https://github.com/houston3) for this clever hack!
85
+
86
+ ## TLS/SSL
87
+
88
+ First, you need to make sure that [openssl](https://github.com/openssl/openssl) is installed correctly, and you have `key.pem` and `cert.pem` files. You can generate them using this command:
89
+
90
+ ``` sh
91
+ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
92
+ ```
93
+
94
+ You will be prompted with a few questions after entering the command. Use `127.0.0.1` as value for `Common name` if you want to be able to install the certificate in your OS's root certificate store or browser so that it is trusted.
95
+
96
+ This generates a cert-key pair and it will be valid for 3650 days (about 10 years).
97
+
98
+ Then you need to run the server with `-S` for enabling SSL and `-C` for your certificate file.
99
+
100
+ ``` sh
101
+ http-server -S -C cert.pem
102
+ ```
103
+
104
+ If you wish to use a passphrase with your private key you can include one in the openssl command via the -passout parameter (using password of foobar)
105
+
106
+
107
+ e.g.
108
+ `openssl req -newkey rsa:2048 -passout pass:foobar -keyout key.pem -x509 -days 365 -out cert.pem`
109
+
110
+ For security reasons, the passphrase will only be read from the `NODE_HTTP_SERVER_SSL_PASSPHRASE` environment variable.
111
+
112
+
113
+ This is what should be output if successful:
114
+
115
+ ``` sh
116
+ Starting up http-server, serving ./ through https
117
+
118
+ http-server settings:
119
+ CORS: disabled
120
+ Cache: 3600 seconds
121
+ Connection Timeout: 120 seconds
122
+ Directory Listings: visible
123
+ AutoIndex: visible
124
+ Serve GZIP Files: false
125
+ Serve Brotli Files: false
126
+ Default File Extension: none
127
+
128
+ Available on:
129
+ https://127.0.0.1:8080
130
+ https://192.168.1.101:8080
131
+ https://192.168.1.104:8080
132
+ Hit CTRL-C to stop the server
133
+ ```
134
+
135
+ # Development
136
+
137
+ Checkout this repository locally, then:
138
+
139
+ ```sh
140
+ $ npm i
141
+ $ npm start
142
+ ```
143
+
144
+ *Now you can visit http://localhost:8080 to view your server*
145
+
146
+ You should see the turtle image in the screenshot above hosted at that URL. See
147
+ the `./public` folder for demo content.
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ var chalk = require('chalk'),
6
+ os = require('os'),
7
+ httpServer = require('../lib/http-server'),
8
+ portfinder = require('portfinder'),
9
+ opener = require('opener'),
10
+
11
+ fs = require('fs'),
12
+ url = require('url');
13
+ var argv = require('minimist')(process.argv.slice(2), {
14
+ alias: {
15
+ tls: 'ssl'
16
+ }
17
+ });
18
+ var ifaces = os.networkInterfaces();
19
+
20
+ process.title = 'http-server';
21
+
22
+ if (argv.h || argv.help) {
23
+ console.log([
24
+ 'usage: http-server [path] [options]',
25
+ '',
26
+ 'options:',
27
+ ' -p --port Port to use. If 0, look for open port. [8080]',
28
+ ' -a Address to use [0.0.0.0]',
29
+ ' -d Show directory listings [true]',
30
+ ' -i Display autoIndex [true]',
31
+ ' -g --gzip Serve gzip files when possible [false]',
32
+ ' -b --brotli Serve brotli files when possible [false]',
33
+ ' If both brotli and gzip are enabled, brotli takes precedence',
34
+ ' -e --ext Default file extension if none supplied [none]',
35
+ ' -s --silent Suppress log messages from output',
36
+ ' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',
37
+ ' Optionally provide CORS headers list separated by commas',
38
+ ' -o [path] Open browser window after starting the server.',
39
+ ' Optionally provide a URL path to open the browser window to.',
40
+ ' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
41
+ ' To disable caching, use -c-1.',
42
+ ' -t Connections timeout in seconds [120], e.g. -t60 for 1 minute.',
43
+ ' To disable timeout, use -t0',
44
+ ' -U --utc Use UTC time format in log messages.',
45
+ ' --log-ip Enable logging of the client\'s IP address',
46
+ '',
47
+ ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
48
+ ' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false',
49
+ '',
50
+ ' --username Username for basic authentication [none]',
51
+ ' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',
52
+ ' --password Password for basic authentication [none]',
53
+ ' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD',
54
+ '',
55
+ ' -S --tls --ssl Enable secure request serving with TLS/SSL (HTTPS)',
56
+ ' -C --cert Path to TLS cert file (default: cert.pem)',
57
+ ' -K --key Path to TLS key file (default: key.pem)',
58
+ '',
59
+ ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',
60
+ ' --no-dotfiles Do not show dotfiles',
61
+ ' --mimetypes Path to a .types file for custom mimetype definition',
62
+ ' -h --help Print this list and exit.',
63
+ ' -v --version Print the version and exit.'
64
+ ].join('\n'));
65
+ process.exit();
66
+ }
67
+
68
+ var port = argv.p || argv.port || parseInt(process.env.PORT, 10),
69
+ host = argv.a || '0.0.0.0',
70
+ tls = argv.S || argv.tls,
71
+ sslPassphrase = process.env.NODE_HTTP_SERVER_SSL_PASSPHRASE,
72
+ proxy = argv.P || argv.proxy,
73
+ proxyOptions = argv['proxy-options'],
74
+ utc = argv.U || argv.utc,
75
+ version = argv.v || argv.version,
76
+ logger;
77
+
78
+ var proxyOptionsBooleanProps = [
79
+ 'ws', 'xfwd', 'secure', 'toProxy', 'prependPath', 'ignorePath', 'changeOrigin',
80
+ 'preserveHeaderKeyCase', 'followRedirects', 'selfHandleResponse'
81
+ ];
82
+
83
+ if (proxyOptions) {
84
+ Object.keys(proxyOptions).forEach(function (key) {
85
+ if (proxyOptionsBooleanProps.indexOf(key) > -1) {
86
+ proxyOptions[key] = proxyOptions[key].toLowerCase() === 'true';
87
+ }
88
+ });
89
+ }
90
+
91
+ if (!argv.s && !argv.silent) {
92
+ logger = {
93
+ info: console.log,
94
+ request: function (req, res, error) {
95
+ var date = utc ? new Date().toUTCString() : new Date();
96
+ var ip = argv['log-ip']
97
+ ? req.headers['x-forwarded-for'] || '' + req.connection.remoteAddress
98
+ : '';
99
+ if (error) {
100
+ logger.info(
101
+ '[%s] %s "%s %s" Error (%s): "%s"',
102
+ date, ip, chalk.red(req.method), chalk.red(req.url),
103
+ chalk.red(error.status.toString()), chalk.red(error.message)
104
+ );
105
+ }
106
+ else {
107
+ logger.info(
108
+ '[%s] %s "%s %s" "%s"',
109
+ date, ip, chalk.cyan(req.method), chalk.cyan(req.url),
110
+ req.headers['user-agent']
111
+ );
112
+ }
113
+ }
114
+ };
115
+ }
116
+ else if (chalk) {
117
+ logger = {
118
+ info: function () {},
119
+ request: function () {}
120
+ };
121
+ }
122
+
123
+ if (version) {
124
+ logger.info('v' + require('../package.json').version);
125
+ process.exit();
126
+ }
127
+
128
+ if (!port) {
129
+ portfinder.basePort = 8080;
130
+ portfinder.getPort(function (err, port) {
131
+ if (err) { throw err; }
132
+ listen(port);
133
+ });
134
+ }
135
+ else {
136
+ listen(port);
137
+ }
138
+
139
+ function listen(port) {
140
+ var options = {
141
+ root: argv._[0],
142
+ cache: argv.c,
143
+ timeout: argv.t,
144
+ showDir: argv.d,
145
+ autoIndex: argv.i,
146
+ gzip: argv.g || argv.gzip,
147
+ brotli: argv.b || argv.brotli,
148
+ robots: argv.r || argv.robots,
149
+ ext: argv.e || argv.ext,
150
+ logFn: logger.request,
151
+ proxy: proxy,
152
+ proxyOptions: proxyOptions,
153
+ showDotfiles: argv.dotfiles,
154
+ mimetypes: argv.mimetypes,
155
+ username: argv.username || process.env.NODE_HTTP_SERVER_USERNAME,
156
+ password: argv.password || process.env.NODE_HTTP_SERVER_PASSWORD
157
+ };
158
+
159
+ if (argv.cors) {
160
+ options.cors = true;
161
+ if (typeof argv.cors === 'string') {
162
+ options.corsHeaders = argv.cors;
163
+ }
164
+ }
165
+
166
+ if (proxy) {
167
+ try {
168
+ new url.URL(proxy)
169
+ }
170
+ catch (err) {
171
+ logger.info(chalk.red('Error: Invalid proxy url'));
172
+ process.exit(1);
173
+ }
174
+ }
175
+
176
+ if (tls) {
177
+ options.https = {
178
+ cert: argv.C || argv.cert || 'cert.pem',
179
+ key: argv.K || argv.key || 'key.pem',
180
+ passphrase: sslPassphrase,
181
+ };
182
+ try {
183
+ fs.lstatSync(options.https.cert);
184
+ }
185
+ catch (err) {
186
+ logger.info(chalk.red('Error: Could not find certificate ' + options.https.cert));
187
+ process.exit(1);
188
+ }
189
+ try {
190
+ fs.lstatSync(options.https.key);
191
+ }
192
+ catch (err) {
193
+ logger.info(chalk.red('Error: Could not find private key ' + options.https.key));
194
+ process.exit(1);
195
+ }
196
+ }
197
+
198
+ var server = httpServer.createServer(options);
199
+ server.listen(port, host, function () {
200
+ var protocol = tls ? 'https://' : 'http://';
201
+
202
+ logger.info([
203
+ chalk.yellow('Starting up http-server, serving '),
204
+ chalk.cyan(server.root),
205
+ tls ? (chalk.yellow(' through') + chalk.cyan(' https')) : ''
206
+ ].join(''));
207
+
208
+ logger.info([chalk.yellow('\nhttp-server version: '), chalk.cyan(require('../package.json').version)].join(''));
209
+
210
+ logger.info([
211
+ chalk.yellow('\nhttp-server settings: '),
212
+ ([chalk.yellow('CORS: '), argv.cors ? chalk.cyan(argv.cors) : chalk.red('disabled')].join('')),
213
+ ([chalk.yellow('Cache: '), argv.c ? (argv.c === '-1' ? chalk.red('disabled') : chalk.cyan(argv.c + ' seconds')) : chalk.cyan('3600 seconds')].join('')),
214
+ ([chalk.yellow('Connection Timeout: '), argv.t === '0' ? chalk.red('disabled') : (argv.t ? chalk.cyan(argv.t + ' seconds') : chalk.cyan('120 seconds'))].join('')),
215
+ ([chalk.yellow('Directory Listings: '), argv.d ? chalk.red('not visible') : chalk.cyan('visible')].join('')),
216
+ ([chalk.yellow('AutoIndex: '), argv.i ? chalk.red('not visible') : chalk.cyan('visible')].join('')),
217
+ ([chalk.yellow('Serve GZIP Files: '), argv.g || argv.gzip ? chalk.cyan('true') : chalk.red('false')].join('')),
218
+ ([chalk.yellow('Serve Brotli Files: '), argv.b || argv.brotli ? chalk.cyan('true') : chalk.red('false')].join('')),
219
+ ([chalk.yellow('Default File Extension: '), argv.e ? chalk.cyan(argv.e) : (argv.ext ? chalk.cyan(argv.ext) : chalk.red('none'))].join(''))
220
+ ].join('\n'));
221
+
222
+ logger.info(chalk.yellow('\nAvailable on:'));
223
+
224
+ if (argv.a && host !== '0.0.0.0') {
225
+ logger.info(` ${protocol}${host}:${chalk.green(port.toString())}`);
226
+ } else {
227
+ Object.keys(ifaces).forEach(function (dev) {
228
+ ifaces[dev].forEach(function (details) {
229
+ if (details.family === 'IPv4') {
230
+ logger.info((' ' + protocol + details.address + ':' + chalk.green(port.toString())));
231
+ }
232
+ });
233
+ });
234
+ }
235
+
236
+ if (typeof proxy === 'string') {
237
+ if (proxyOptions) {
238
+ logger.info('Unhandled requests will be served from: ' + proxy + '. Options: ' + JSON.stringify(proxyOptions));
239
+ }
240
+ else {
241
+ logger.info('Unhandled requests will be served from: ' + proxy);
242
+ }
243
+ }
244
+
245
+ logger.info('Hit CTRL-C to stop the server');
246
+ if (argv.o) {
247
+ const openHost = host === '0.0.0.0' ? '127.0.0.1' : host;
248
+ let openUrl = `${protocol}${openHost}:${port}`;
249
+ if (typeof argv.o === 'string') {
250
+ openUrl += argv.o[0] === '/' ? argv.o : '/' + argv.o;
251
+ }
252
+ logger.info('Open: ' + openUrl);
253
+ opener(openUrl);
254
+ }
255
+
256
+ // Spacing before logs
257
+ if (!argv.s) logger.info();
258
+ });
259
+ }
260
+
261
+ if (process.platform === 'win32') {
262
+ require('readline').createInterface({
263
+ input: process.stdin,
264
+ output: process.stdout
265
+ }).on('SIGINT', function () {
266
+ process.emit('SIGINT');
267
+ });
268
+ }
269
+
270
+ process.on('SIGINT', function () {
271
+ logger.info(chalk.red('http-server stopped.'));
272
+ process.exit();
273
+ });
274
+
275
+ process.on('SIGTERM', function () {
276
+ logger.info(chalk.red('http-server stopped.'));
277
+ process.exit();
278
+ });
@@ -0,0 +1,165 @@
1
+ .TH http-server 1 "April 2020" GNU "http-server man page"
2
+
3
+ .SH NAME
4
+ http-server \- a simple zero-configuration command-line http server
5
+
6
+ .SH SYNOPSIS
7
+ .B http-server
8
+ [\fIPATH\fR]
9
+ [\fIOPTIONS\fR]
10
+
11
+ .SH DESCRIPTION
12
+ \fBhttp-server\fR is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
13
+
14
+ .SH OPTIONS
15
+
16
+ .TP
17
+ .BI [\fIPATH\fR]
18
+ The directory to serve.
19
+ Defaults to ./public if it exists, and ./ otherwise.
20
+
21
+ .TP
22
+ .BI \-p ", " \-\-port " " \fIPORT\fR
23
+ Port to use. If 0, look for the first available port, starting at 8080.
24
+ Default is 8080.
25
+
26
+ .TP
27
+ .BI \-a " " \fIADDRESS\fR
28
+ Address to use.
29
+ Default is 0.0.0.0.
30
+
31
+ .TP
32
+ .BI \-d
33
+ Show directory listings.
34
+ Default is true.
35
+
36
+ .TP
37
+ .BI \-i
38
+ Display autoIndex.
39
+ Default is true.
40
+
41
+ .TP
42
+ .BI \-g ", " \-\-gzip
43
+ Serve gzip files when possible.
44
+ Default is false.
45
+
46
+ .TP
47
+ .BI \-b ", " \-\-brotli
48
+ Serve brotli files when possible.
49
+ If both brotli and gzip are enabled, brotli takes precedence.
50
+ Default is false.
51
+
52
+ .TP
53
+ .BI \-e ", " \-\-ext " " \fIEXTENSION\fR
54
+ Default file extension is none is provided.
55
+
56
+ .TP
57
+ .BI \-s ", " \-\-silent
58
+ Suppress log messages from output.
59
+
60
+ .TP
61
+ .BI \-\-cors " " [\fIHEADERS\fR]
62
+ Enable CORS via the "Access-Control-Allow-Origin" header.
63
+ Optionally provide CORS headers list separated by commas.
64
+
65
+ .TP
66
+ .BI \-o " " [\fIPATH\fR]
67
+ Open default browser window after starting the server.
68
+ Optionally provide a URL path to open the browser window to.
69
+
70
+ .TP
71
+ .BI \-c " " \fITIME\fR
72
+ Cache time (max-age) in seconds.
73
+ To disable caching, use \-c \-1.
74
+ Default is 3600.
75
+
76
+ .TP
77
+ .BI \-U ", " \-\-utc
78
+ Use UTC time format in log messages.
79
+
80
+ .TP
81
+ .BI \-\-log\-ip
82
+ Enable logging of the client IP address.
83
+
84
+ .TP
85
+ .BI \-P ", " \-\-proxy
86
+ Fallback proxy if the request cannot be resolved.
87
+
88
+ .TP
89
+ .BI \-\-proxy\-options
90
+ Pass proxy options using nested dotted objects.
91
+
92
+ .TP
93
+ .BI \-\-username " " \fIUSERNAME\fR
94
+ Username for basic authentication.
95
+ Can also be specified with the environment variable NODE_HTTP_SERVER_USERNAME.
96
+ Defaults to none.
97
+
98
+ .TP
99
+ .BI \-\-password " " \fIPASSWORD\fR
100
+ Password for basic authentication.
101
+ Can also be specified with the environment variable NODE_HTTP_SERVER_PASSWORD.
102
+ Defaults to none.
103
+
104
+ .TP
105
+ .BI \-S ", " \-\-tls ", " \-\-ssl
106
+ Enable https.
107
+
108
+ .TP
109
+ .BI \-C ", " \-\-cert " " [\fIFILE\fR]
110
+ Path to SSL certificate file.
111
+ If not specified, uses cert.pem.
112
+
113
+ .TP
114
+ .BI \-K ", " \-\-key " " [\fIFILE\fR]
115
+ Path to SSL key file.
116
+ If not specified, uses key.pem.
117
+ Passphrase will be read from NODE_HTTP_SERVER_SSL_PASSPHRASE (if set)
118
+
119
+ .TP
120
+ .BI \-r ", " \-\-robots " " [\fIUSER\-AGENT\fR]
121
+ Respond to /robots.txt request.
122
+ If not specified, uses "User-agent: *\\nDisallow: /]"
123
+
124
+ .TP
125
+ .BI \-\-no\-dotfiles
126
+ Do not show dotfiles.
127
+
128
+ .TP
129
+ .BI \-h ", " \-\-help
130
+ Print usage and exit.
131
+
132
+ .TP
133
+ .BI \-v ", " \-\-version
134
+ Print version and exit.
135
+
136
+ .SH FILES
137
+ .B index.html
138
+ will be served as the default file to any directory requests.
139
+
140
+ .B 404.html
141
+ will be served if a file is not found. This can be used for SPA hosting to serve the entry page.
142
+
143
+ .SH COPYING
144
+ Copyright (c) 2011-2022 Charlie Robbins, Marak Squires, and the Contributors.
145
+ Permission is hereby granted, free of charge, to any person obtaining
146
+ a copy of this software and associated documentation files (the
147
+ "Software"), to deal in the Software without restriction, including
148
+ without limitation the rights to use, copy, modify, merge, publish,
149
+ distribute, sublicense, and/or sell copies of the Software, and to
150
+ permit persons to whom the Software is furnished to do so, subject to
151
+ the following conditions:
152
+
153
+ The above copyright notice and this permission notice shall be
154
+ included in all copies or substantial portions of the Software.
155
+
156
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
157
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
158
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
159
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
160
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
161
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
162
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
163
+
164
+ .SH VERSION
165
+ Version 0.12.2
@@ -0,0 +1,34 @@
1
+ {
2
+ "autoIndex": [ "autoIndex", "autoindex" ],
3
+ "showDir": [ "showDir", "showdir" ],
4
+ "showDotfiles": ["showDotfiles", "showdotfiles"],
5
+ "humanReadable": [ "humanReadable", "humanreadable", "human-readable" ],
6
+ "hidePermissions": ["hidePermissions", "hidepermissions", "hide-permissions"],
7
+ "si": [ "si", "index" ],
8
+ "handleError": [ "handleError", "handleerror" ],
9
+ "cors": [ "cors", "CORS" ],
10
+ "headers": [ "H", "header", "headers" ],
11
+ "contentType": [ "contentType", "contenttype", "content-type" ],
12
+ "mimeType": [
13
+ "mimetype",
14
+ "mimetypes",
15
+ "mimeType",
16
+ "mimeTypes",
17
+ "mime-type",
18
+ "mime-types",
19
+ "mime-Type",
20
+ "mime-Types"
21
+ ],
22
+ "weakEtags": [ "weakEtags", "weaketags", "weak-etags" ],
23
+ "weakCompare": [
24
+ "weakcompare",
25
+ "weakCompare",
26
+ "weak-compare",
27
+ "weak-Compare"
28
+ ],
29
+ "handleOptionsMethod": [
30
+ "handleOptionsMethod",
31
+ "handleoptionsmethod",
32
+ "handle-options-method"
33
+ ]
34
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "autoIndex": true,
3
+ "showDir": true,
4
+ "showDotfiles": true,
5
+ "humanReadable": true,
6
+ "hidePermissions": false,
7
+ "si": false,
8
+ "cache": "max-age=3600",
9
+ "cors": false,
10
+ "gzip": true,
11
+ "brotli": false,
12
+ "defaultExt": ".html",
13
+ "handleError": true,
14
+ "contentType": "application/octet-stream",
15
+ "weakEtags": true,
16
+ "weakCompare": true,
17
+ "handleOptionsMethod": false
18
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ module.exports = (stat, weakEtag) => {
4
+ let etag = `"${[stat.ino, stat.size, stat.mtime.toISOString()].join('-')}"`;
5
+ if (weakEtag) {
6
+ etag = `W/${etag}`;
7
+ }
8
+ return etag;
9
+ };