woodland 21.0.7 → 21.0.8
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/README.md +1 -64
- package/dist/cli.cjs +1 -1
- package/dist/woodland.cjs +4 -4
- package/dist/woodland.js +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -275,7 +275,7 @@ class API extends Woodland {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
getUsers(req, res) {
|
|
278
|
-
|
|
278
|
+
res.json([]);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -309,17 +309,6 @@ app.always(globalMiddleware); // Wildcard for all methods
|
|
|
309
309
|
app.get("/resource", handler); // Handles both GET and HEAD
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
-
## Environment Variables
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
# Logging configuration
|
|
316
|
-
export WOODLAND_LOG_ENABLED=true
|
|
317
|
-
export WOODLAND_LOG_FORMAT="%h %l %u %t \"%r\" %>s %b"
|
|
318
|
-
export WOODLAND_LOG_LEVEL=debug
|
|
319
|
-
|
|
320
|
-
# Override config at runtime
|
|
321
|
-
```
|
|
322
|
-
|
|
323
312
|
## Middleware Registry
|
|
324
313
|
|
|
325
314
|
```javascript
|
|
@@ -371,34 +360,6 @@ if (!ignored.has(fn)) {
|
|
|
371
360
|
|
|
372
361
|
// Use Object.create(null) for null-prototype objects
|
|
373
362
|
const headers = Object.create(null);
|
|
374
|
-
|
|
375
|
-
// Cache regex patterns at module level
|
|
376
|
-
const MY_PATTERN = /^pattern$/;
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
## Factory Pattern
|
|
380
|
-
|
|
381
|
-
Woodland uses factory functions for creating instances:
|
|
382
|
-
|
|
383
|
-
```javascript
|
|
384
|
-
// Recommended: Factory function
|
|
385
|
-
const app = woodland({ autoIndex: true });
|
|
386
|
-
|
|
387
|
-
// Alternative: Class-based (for larger apps)
|
|
388
|
-
import { Woodland } from "woodland";
|
|
389
|
-
|
|
390
|
-
class API extends Woodland {
|
|
391
|
-
constructor() {
|
|
392
|
-
super({ origins: ["https://myapp.com"] });
|
|
393
|
-
this.setupRoutes();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
setupRoutes() {
|
|
397
|
-
this.get("/health", () => res.json({ status: "ok" }));
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const api = new API();
|
|
402
363
|
```
|
|
403
364
|
|
|
404
365
|
## File Server
|
|
@@ -453,9 +414,6 @@ woodland --port=3000
|
|
|
453
414
|
# Custom IP
|
|
454
415
|
woodland --ip=0.0.0.0
|
|
455
416
|
|
|
456
|
-
# Enable file serving
|
|
457
|
-
woodland --files
|
|
458
|
-
|
|
459
417
|
# Verbose logging
|
|
460
418
|
woodland --verbose
|
|
461
419
|
```
|
|
@@ -470,27 +428,6 @@ npm run lint # Check linting
|
|
|
470
428
|
npm run fix # Fix linting issues
|
|
471
429
|
```
|
|
472
430
|
|
|
473
|
-
## Performance Patterns
|
|
474
|
-
|
|
475
|
-
**Caching:**
|
|
476
|
-
|
|
477
|
-
```javascript
|
|
478
|
-
// LRU cache via tiny-lru (default: 1000 entries, 10s TTL)
|
|
479
|
-
const app = woodland({ cacheSize: 1000, cacheTTL: 10000 });
|
|
480
|
-
|
|
481
|
-
// ETag support via tiny-etag (default: enabled)
|
|
482
|
-
const app = woodland({ etags: true });
|
|
483
|
-
|
|
484
|
-
// File stats are read fresh each time (no caching for accuracy)
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
**Optimization Tips:**
|
|
488
|
-
|
|
489
|
-
- Use `app.allowed("GET", "/users")` to check if method is allowed
|
|
490
|
-
- Use `app.list("get", "array")` to list all routes for a method
|
|
491
|
-
- Cache regex patterns at module level for repeated use
|
|
492
|
-
- Use `Set` for O(1) lookups instead of array `.includes()`
|
|
493
|
-
|
|
494
431
|
## Benchmarks
|
|
495
432
|
|
|
496
433
|
**Performance comparison (mean of 5 runs):**
|
package/dist/cli.cjs
CHANGED
package/dist/woodland.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
5
|
* @license BSD-3-Clause
|
|
6
|
-
* @version 21.0.
|
|
6
|
+
* @version 21.0.8
|
|
7
7
|
*/
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
@@ -389,9 +389,9 @@ function getStatusText(status) {
|
|
|
389
389
|
* Error response handler
|
|
390
390
|
* @param {Object} req - Request object
|
|
391
391
|
* @param {Object} res - Response object
|
|
392
|
-
* @param {number} [status=
|
|
392
|
+
* @param {number} [status=res.statusCode] - HTTP status code (coerces to 500 if < 400)
|
|
393
393
|
*/
|
|
394
|
-
function error(req, res, status = res.
|
|
394
|
+
function error(req, res, status = res.statusCode) {
|
|
395
395
|
if (res.headersSent === false) {
|
|
396
396
|
if (status < INT_400) {
|
|
397
397
|
status = 500;
|
|
@@ -1680,7 +1680,7 @@ class Woodland extends node_events.EventEmitter {
|
|
|
1680
1680
|
result = list.sort().join(COMMA_SPACE);
|
|
1681
1681
|
this.permissions.set(uri, result);
|
|
1682
1682
|
this.logger.log(
|
|
1683
|
-
`type=allows, uri=${uri}, override=${override}, message="Determined 'allow' header
|
|
1683
|
+
`type=allows, uri=${uri}, override=${override}, message="Determined 'allow' header value"`,
|
|
1684
1684
|
);
|
|
1685
1685
|
}
|
|
1686
1686
|
|
package/dist/woodland.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
5
5
|
* @license BSD-3-Clause
|
|
6
|
-
* @version 21.0.
|
|
6
|
+
* @version 21.0.8
|
|
7
7
|
*/
|
|
8
8
|
import {STATUS_CODES}from'node:http';import {EventEmitter}from'node:events';import {readFileSync,createReadStream}from'node:fs';import {etag}from'tiny-etag';import {lru}from'tiny-lru';import {precise}from'precise';import {createRequire}from'node:module';import {join,extname,resolve}from'node:path';import {fileURLToPath,URL as URL$1}from'node:url';import mimeDb from'mime-db';import {coerce}from'tiny-coerce';import {Validator}from'jsonschema';import {stat,readdir}from'node:fs/promises';const __dirname$2 = fileURLToPath(new URL$1(".", import.meta.url));
|
|
9
9
|
const require$1 = createRequire(import.meta.url);
|
|
@@ -370,9 +370,9 @@ function getStatusText(status) {
|
|
|
370
370
|
* Error response handler
|
|
371
371
|
* @param {Object} req - Request object
|
|
372
372
|
* @param {Object} res - Response object
|
|
373
|
-
* @param {number} [status=
|
|
373
|
+
* @param {number} [status=res.statusCode] - HTTP status code (coerces to 500 if < 400)
|
|
374
374
|
*/
|
|
375
|
-
function error(req, res, status = res.
|
|
375
|
+
function error(req, res, status = res.statusCode) {
|
|
376
376
|
if (res.headersSent === false) {
|
|
377
377
|
if (status < INT_400) {
|
|
378
378
|
status = 500;
|
|
@@ -1649,7 +1649,7 @@ class Woodland extends EventEmitter {
|
|
|
1649
1649
|
result = list.sort().join(COMMA_SPACE);
|
|
1650
1650
|
this.permissions.set(uri, result);
|
|
1651
1651
|
this.logger.log(
|
|
1652
|
-
`type=allows, uri=${uri}, override=${override}, message="Determined 'allow' header
|
|
1652
|
+
`type=allows, uri=${uri}, override=${override}, message="Determined 'allow' header value"`,
|
|
1653
1653
|
);
|
|
1654
1654
|
}
|
|
1655
1655
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "woodland",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.8",
|
|
4
4
|
"description": "High-performance HTTP framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"auto-changelog": "^2.5.0",
|
|
68
68
|
"husky": "^9.1.0",
|
|
69
|
-
"oxfmt": "^0.
|
|
69
|
+
"oxfmt": "^0.42.0",
|
|
70
70
|
"oxlint": "^1.55.0",
|
|
71
71
|
"rimraf": "^6.0.1",
|
|
72
72
|
"rollup": "^4.50.1"
|