woodland 18.2.2 → 18.2.4
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/dist/cli.cjs +21 -20
- package/dist/woodland.cjs +33 -33
- package/dist/woodland.js +9 -9
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* woodland
|
|
4
|
-
*
|
|
5
|
-
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
6
|
-
* @license BSD-3-Clause
|
|
7
|
-
* @version 18.2.
|
|
8
|
-
*/
|
|
9
|
-
'use strict';
|
|
10
|
-
|
|
11
|
-
var node_http = require('node:http');
|
|
12
|
-
var tinyCoerce = require('tiny-coerce');
|
|
13
|
-
var woodland = require('woodland');
|
|
14
|
-
var node_module = require('node:module');
|
|
15
|
-
var node_path = require('node:path');
|
|
16
|
-
var node_url = require('node:url');
|
|
17
|
-
|
|
18
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
2
|
+
/**
|
|
3
|
+
* woodland
|
|
4
|
+
*
|
|
5
|
+
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
6
|
+
* @license BSD-3-Clause
|
|
7
|
+
* @version 18.2.4
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
var node_http = require('node:http');
|
|
12
|
+
var tinyCoerce = require('tiny-coerce');
|
|
13
|
+
var woodland = require('woodland');
|
|
14
|
+
var node_module = require('node:module');
|
|
15
|
+
var node_path = require('node:path');
|
|
16
|
+
var node_url = require('node:url');
|
|
17
|
+
|
|
18
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
19
19
|
const __dirname$1 = node_url.fileURLToPath(new node_url.URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
|
|
20
20
|
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
|
21
21
|
require$1(node_path.join(__dirname$1, "..", "package.json"));
|
|
@@ -25,6 +25,7 @@ const CONTENT_TYPE = "content-type";
|
|
|
25
25
|
const EQUAL = "=";
|
|
26
26
|
const EN_US = "en-US";
|
|
27
27
|
const HYPHEN = "-";
|
|
28
|
+
const INFO = "info";
|
|
28
29
|
const INT_8000 = 8000;
|
|
29
30
|
const LOCALHOST = "127.0.0.1";
|
|
30
31
|
const SHORT = "short";
|
|
@@ -36,8 +37,8 @@ Object.freeze(Array.from(Array(12).values()).map((i, idx) => {
|
|
|
36
37
|
}));
|
|
37
38
|
const NO_CACHE = "no-cache";
|
|
38
39
|
const TEXT_PLAIN = "text/plain";
|
|
39
|
-
`nodejs/${process.version}, ${process.platform}/${process.arch}`;
|
|
40
|
-
|
|
40
|
+
`nodejs/${process.version}, ${process.platform}/${process.arch}`;
|
|
41
|
+
|
|
41
42
|
const app = woodland.woodland({
|
|
42
43
|
autoindex: true,
|
|
43
44
|
defaultHeaders: {[CACHE_CONTROL]: NO_CACHE, [CONTENT_TYPE]: `${TEXT_PLAIN}; ${CHAR_SET}`},
|
|
@@ -55,4 +56,4 @@ const app = woodland.woodland({
|
|
|
55
56
|
|
|
56
57
|
app.staticFiles();
|
|
57
58
|
node_http.createServer(app.route).listen(port, ip);
|
|
58
|
-
app.log(`id=woodland, hostname=localhost, ip=${ip}, port=${port}
|
|
59
|
+
app.log(`id=woodland, hostname=localhost, ip=${ip}, port=${port}`, INFO);
|
package/dist/woodland.cjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* woodland
|
|
3
|
-
*
|
|
4
|
-
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
|
-
* @license BSD-3-Clause
|
|
6
|
-
* @version 18.2.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
var node_http = require('node:http');
|
|
11
|
-
var node_path = require('node:path');
|
|
12
|
-
var node_events = require('node:events');
|
|
13
|
-
var promises = require('node:fs/promises');
|
|
14
|
-
var tinyEtag = require('tiny-etag');
|
|
15
|
-
var precise = require('precise');
|
|
16
|
-
var tinyLru = require('tiny-lru');
|
|
17
|
-
var node_module = require('node:module');
|
|
18
|
-
var node_url = require('node:url');
|
|
19
|
-
var node_fs = require('node:fs');
|
|
20
|
-
var tinyCoerce = require('tiny-coerce');
|
|
21
|
-
var mimeDb = require('mime-db');
|
|
22
|
-
|
|
23
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
1
|
+
/**
|
|
2
|
+
* woodland
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
|
+
* @license BSD-3-Clause
|
|
6
|
+
* @version 18.2.4
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var node_http = require('node:http');
|
|
11
|
+
var node_path = require('node:path');
|
|
12
|
+
var node_events = require('node:events');
|
|
13
|
+
var promises = require('node:fs/promises');
|
|
14
|
+
var tinyEtag = require('tiny-etag');
|
|
15
|
+
var precise = require('precise');
|
|
16
|
+
var tinyLru = require('tiny-lru');
|
|
17
|
+
var node_module = require('node:module');
|
|
18
|
+
var node_url = require('node:url');
|
|
19
|
+
var node_fs = require('node:fs');
|
|
20
|
+
var tinyCoerce = require('tiny-coerce');
|
|
21
|
+
var mimeDb = require('mime-db');
|
|
22
|
+
|
|
23
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
24
24
|
const __dirname$2 = node_url.fileURLToPath(new node_url.URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('woodland.cjs', document.baseURI).href))));
|
|
25
25
|
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('woodland.cjs', document.baseURI).href)));
|
|
26
26
|
const {name, version} = require$1(node_path.join(__dirname$2, "..", "package.json"));
|
|
@@ -162,8 +162,8 @@ const WILDCARD = "*";
|
|
|
162
162
|
const X_FORWARDED_FOR = "x-forwarded-for";
|
|
163
163
|
const X_POWERED_BY = "x-powered-by";
|
|
164
164
|
const X_POWERED_BY_VALUE = `nodejs/${process.version}, ${process.platform}/${process.arch}`;
|
|
165
|
-
const X_RESPONSE_TIME = "x-response-time";
|
|
166
|
-
|
|
165
|
+
const X_RESPONSE_TIME = "x-response-time";
|
|
166
|
+
|
|
167
167
|
const __dirname$1 = node_url.fileURLToPath(new node_url.URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('woodland.cjs', document.baseURI).href)))),
|
|
168
168
|
html = node_fs.readFileSync(node_path.join(__dirname$1, "..", "tpl", "autoindex.html"), {encoding: UTF8}),
|
|
169
169
|
valid = Object.entries(mimeDb).filter(i => EXTENSIONS in i[1]),
|
|
@@ -362,8 +362,8 @@ function timeOffset (arg = INT_0) {
|
|
|
362
362
|
|
|
363
363
|
function writeHead (res, headers = {}) {
|
|
364
364
|
res.writeHead(res.statusCode, node_http.STATUS_CODES[res.statusCode], headers);
|
|
365
|
-
}
|
|
366
|
-
|
|
365
|
+
}
|
|
366
|
+
|
|
367
367
|
class Woodland extends node_events.EventEmitter {
|
|
368
368
|
constructor ({
|
|
369
369
|
autoindex = false,
|
|
@@ -796,7 +796,7 @@ class Woodland extends node_events.EventEmitter {
|
|
|
796
796
|
};
|
|
797
797
|
}
|
|
798
798
|
|
|
799
|
-
async serve (req, res, arg =
|
|
799
|
+
async serve (req, res, arg = EMPTY, folder = process.cwd(), index = this.indexes) {
|
|
800
800
|
const fp = node_path.resolve(folder, decodeURIComponent(arg));
|
|
801
801
|
|
|
802
802
|
if (req.method !== GET && req.method !== HEAD && req.method !== OPTIONS) {
|
|
@@ -873,7 +873,7 @@ class Woodland extends node_events.EventEmitter {
|
|
|
873
873
|
};
|
|
874
874
|
}
|
|
875
875
|
|
|
876
|
-
staticFiles (root =
|
|
876
|
+
staticFiles (root = SLASH) {
|
|
877
877
|
/* istanbul ignore next */
|
|
878
878
|
this.get(`${root}(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1)));
|
|
879
879
|
}
|
|
@@ -938,7 +938,7 @@ function woodland (arg) {
|
|
|
938
938
|
app.route = app.route.bind(app);
|
|
939
939
|
|
|
940
940
|
return app;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
exports.Woodland = Woodland;
|
|
944
|
-
exports.woodland = woodland;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
exports.Woodland = Woodland;
|
|
944
|
+
exports.woodland = woodland;
|
package/dist/woodland.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* woodland
|
|
3
|
-
*
|
|
4
|
-
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
|
-
* @license BSD-3-Clause
|
|
6
|
-
* @version 18.2.
|
|
7
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* woodland
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2023 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
|
+
* @license BSD-3-Clause
|
|
6
|
+
* @version 18.2.4
|
|
7
|
+
*/
|
|
8
8
|
import {STATUS_CODES,METHODS}from'node:http';import {join,extname,resolve}from'node:path';import {EventEmitter}from'node:events';import {stat,readdir}from'node:fs/promises';import {etag}from'tiny-etag';import {precise}from'precise';import {lru}from'tiny-lru';import {createRequire}from'node:module';import {fileURLToPath,URL}from'node:url';import {readFileSync,createReadStream}from'node:fs';import {coerce}from'tiny-coerce';import mimeDb from'mime-db';const __dirname$1 = fileURLToPath(new URL(".", import.meta.url));
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
const {name, version} = require(join(__dirname$1, "..", "package.json"));
|
|
@@ -776,7 +776,7 @@ function writeHead (res, headers = {}) {
|
|
|
776
776
|
};
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
async serve (req, res, arg =
|
|
779
|
+
async serve (req, res, arg = EMPTY, folder = process.cwd(), index = this.indexes) {
|
|
780
780
|
const fp = resolve(folder, decodeURIComponent(arg));
|
|
781
781
|
|
|
782
782
|
if (req.method !== GET && req.method !== HEAD && req.method !== OPTIONS) {
|
|
@@ -853,7 +853,7 @@ function writeHead (res, headers = {}) {
|
|
|
853
853
|
};
|
|
854
854
|
}
|
|
855
855
|
|
|
856
|
-
staticFiles (root =
|
|
856
|
+
staticFiles (root = SLASH) {
|
|
857
857
|
/* istanbul ignore next */
|
|
858
858
|
this.get(`${root}(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1)));
|
|
859
859
|
}
|