koa-classic-server 3.0.1 → 3.1.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.
Files changed (106) hide show
  1. package/README.md +44 -120
  2. package/index.cjs +200 -21
  3. package/package.json +10 -5
  4. package/.github/workflows/npm-publish.yml +0 -98
  5. package/CLAUDE.md +0 -101
  6. package/__tests__/benchmark-results-baseline-v1.2.0.txt +0 -354
  7. package/__tests__/benchmark-results-optimized-v2.0.0.txt +0 -354
  8. package/__tests__/benchmark-results-v3.0.0.txt +0 -372
  9. package/__tests__/benchmark.js +0 -239
  10. package/__tests__/caching-headers.test.js +0 -556
  11. package/__tests__/compression-fixtures/data.json +0 -1
  12. package/__tests__/compression-fixtures/large.txt +0 -1
  13. package/__tests__/compression-fixtures/small.txt +0 -1
  14. package/__tests__/compression.test.js +0 -284
  15. package/__tests__/customTest/README.md +0 -6
  16. package/__tests__/customTest/loadConfig.util.js +0 -41
  17. package/__tests__/customTest/serversToLoad.util.js +0 -93
  18. package/__tests__/demo-regex-index.js +0 -140
  19. package/__tests__/deprecation-warnings.test.js +0 -105
  20. package/__tests__/directory-sorting-links.test.js +0 -135
  21. package/__tests__/dt-unknown.test.js +0 -635
  22. package/__tests__/ejs.test.js +0 -299
  23. package/__tests__/head-method.test.js +0 -160
  24. package/__tests__/hidden-fixtures/.dot-dir/inside.txt +0 -1
  25. package/__tests__/hidden-fixtures/.env +0 -2
  26. package/__tests__/hidden-fixtures/.well-known/acme-challenge.txt +0 -1
  27. package/__tests__/hidden-fixtures/config/secrets/password.txt +0 -1
  28. package/__tests__/hidden-fixtures/data.key +0 -1
  29. package/__tests__/hidden-fixtures/file.secret +0 -1
  30. package/__tests__/hidden-fixtures/index.html +0 -1
  31. package/__tests__/hidden-fixtures/normal.txt +0 -1
  32. package/__tests__/hidden-fixtures/subdir/.env +0 -1
  33. package/__tests__/hidden-fixtures/subdir/regular.txt +0 -1
  34. package/__tests__/hidden-option.test.js +0 -407
  35. package/__tests__/hideExtension.test.js +0 -607
  36. package/__tests__/index-option.test.js +0 -449
  37. package/__tests__/index.test.js +0 -345
  38. package/__tests__/listing.test.js +0 -437
  39. package/__tests__/logger.test.js +0 -232
  40. package/__tests__/performance.test.js +0 -370
  41. package/__tests__/publicWwwTest/cartella/sottocartella/ciao.html +0 -11
  42. package/__tests__/publicWwwTest/cartella/sottocartella/provaEjs/testEjs.ejs +0 -11
  43. package/__tests__/publicWwwTest/cartella vuota con spazi nel nome/file con spazio nel nome .txt +0 -1
  44. package/__tests__/publicWwwTest/cartella vuota con spazi nel nome /file con spazio nel nome .txt +0 -1
  45. package/__tests__/publicWwwTest/ejs-templates/complex.ejs +0 -56
  46. package/__tests__/publicWwwTest/ejs-templates/index.ejs +0 -30
  47. package/__tests__/publicWwwTest/ejs-templates/simple.ejs +0 -13
  48. package/__tests__/publicWwwTest/ejs-templates/with-conditional.ejs +0 -28
  49. package/__tests__/publicWwwTest/ejs-templates/with-escaping.ejs +0 -26
  50. package/__tests__/publicWwwTest/ejs-templates/with-loop.ejs +0 -16
  51. package/__tests__/publicWwwTest/hideext-test/about/index.html +0 -1
  52. package/__tests__/publicWwwTest/hideext-test/about.EJS +0 -1
  53. package/__tests__/publicWwwTest/hideext-test/about.ejs +0 -2
  54. package/__tests__/publicWwwTest/hideext-test/blog/articolo.ejs +0 -2
  55. package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina +0 -1
  56. package/__tests__/publicWwwTest/hideext-test/conflict-test/pagina.ejs +0 -1
  57. package/__tests__/publicWwwTest/hideext-test/file.ejs.bak +0 -1
  58. package/__tests__/publicWwwTest/hideext-test/index.ejs +0 -2
  59. package/__tests__/publicWwwTest/hideext-test/photo.txt +0 -1
  60. package/__tests__/publicWwwTest/hideext-test/sezione/index.ejs +0 -1
  61. package/__tests__/publicWwwTest/hideext-test/style.css +0 -1
  62. package/__tests__/publicWwwTest/ile_vuoto.txt +0 -0
  63. package/__tests__/publicWwwTest/index.html +0 -11
  64. package/__tests__/publicWwwTest/prova file .txt +0 -2
  65. package/__tests__/publicWwwTest/semplicetxt.txt +0 -1
  66. package/__tests__/publicWwwTest/test-page.html +0 -1
  67. package/__tests__/publicWwwTest/test.txt +0 -1
  68. package/__tests__/range-fixtures/sample.txt +0 -1
  69. package/__tests__/range.test.js +0 -223
  70. package/__tests__/security-headers.test.js +0 -165
  71. package/__tests__/security.test.js +0 -322
  72. package/__tests__/server-cache-fixtures/large.txt +0 -1
  73. package/__tests__/server-cache-fixtures/small.txt +0 -1
  74. package/__tests__/server-cache.test.js +0 -594
  75. package/__tests__/setup-benchmark.js +0 -178
  76. package/__tests__/symlink.test.js +0 -441
  77. package/__tests__/template-timeout.test.js +0 -321
  78. package/__tests__/test-regex-quick.js +0 -158
  79. package/__tests__/useOriginalUrl.test.js +0 -213
  80. package/docs/ACTION_PLAN.md +0 -293
  81. package/docs/BENCHMARKS.md +0 -317
  82. package/docs/CHANGELOG.md +0 -906
  83. package/docs/CODE_REVIEW.md +0 -300
  84. package/docs/DEBUG_REPORT.md +0 -593
  85. package/docs/DOCUMENTATION.md +0 -1864
  86. package/docs/EXAMPLES_INDEX_OPTION.md +0 -395
  87. package/docs/FLOW_DIAGRAM.md +0 -954
  88. package/docs/INDEX_OPTION_PRIORITY.md +0 -527
  89. package/docs/OPTIMIZATION_HTTP_CACHING.md +0 -689
  90. package/docs/OPTIMIZATION_ROADMAP_for_V3.md +0 -864
  91. package/docs/PERFORMANCE_ANALYSIS.md +0 -839
  92. package/docs/PERFORMANCE_COMPARISON.md +0 -388
  93. package/docs/noteExports.md +0 -148
  94. package/docs/security_improvement_for_V3.md +0 -421
  95. package/docs/template-engine/TEMPLATE_ENGINE_GUIDE.md +0 -1734
  96. package/docs/template-engine/esempi-incrementali.js +0 -192
  97. package/docs/template-engine/examples/esempio1-nessun-dato.ejs +0 -12
  98. package/docs/template-engine/examples/esempio2-una-variabile.ejs +0 -11
  99. package/docs/template-engine/examples/esempio3-piu-variabili.ejs +0 -15
  100. package/docs/template-engine/examples/esempio4-condizionale.ejs +0 -18
  101. package/docs/template-engine/examples/esempio5-loop.ejs +0 -18
  102. package/docs/template-engine/examples/index-esempi.html +0 -181
  103. package/docs/template-engine/examples/index.html +0 -40
  104. package/docs/template-engine/examples/test.ejs +0 -64
  105. package/eslint.config.mjs +0 -17
  106. package/jest.config.js +0 -18
@@ -1,98 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to npm when a release is published
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Publish to npm
5
-
6
- on:
7
- release:
8
- types: [published]
9
-
10
- # Prevent multiple concurrent publish workflows
11
- concurrency:
12
- group: npm-publish-${{ github.ref }}
13
- cancel-in-progress: false
14
-
15
- # Set permissions for the workflow
16
- permissions:
17
- contents: read
18
- id-token: write # Required for npm provenance
19
-
20
- jobs:
21
- build:
22
- name: Build and Test
23
- runs-on: ubuntu-latest
24
- timeout-minutes: 10
25
-
26
- steps:
27
- - name: Checkout code
28
- uses: actions/checkout@v4
29
-
30
- - name: Setup Node.js
31
- uses: actions/setup-node@v4
32
- with:
33
- node-version: 20
34
- cache: 'npm'
35
-
36
- - name: Install dependencies
37
- run: npm ci
38
-
39
- - name: Run tests
40
- run: npm test --if-present
41
-
42
- - name: Build package
43
- run: npm run build --if-present
44
-
45
- - name: Cache build artifacts
46
- uses: actions/cache/save@v4
47
- with:
48
- path: |
49
- node_modules
50
- dist
51
- build
52
- key: build-${{ github.sha }}
53
-
54
- publish-npm:
55
- name: Publish to npm Registry
56
- needs: build
57
- runs-on: ubuntu-latest
58
- timeout-minutes: 10
59
-
60
- steps:
61
- - name: Checkout code
62
- uses: actions/checkout@v4
63
-
64
- - name: Setup Node.js
65
- uses: actions/setup-node@v4
66
- with:
67
- node-version: 20
68
- registry-url: https://registry.npmjs.org/
69
- cache: 'npm'
70
-
71
- - name: Restore build artifacts
72
- uses: actions/cache/restore@v4
73
- with:
74
- path: |
75
- node_modules
76
- dist
77
- build
78
- key: build-${{ github.sha }}
79
-
80
- - name: Verify package version matches release tag
81
- run: |
82
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
83
- RELEASE_TAG=${GITHUB_REF#refs/tags/}
84
- # Remove 'v' prefix if present in tag
85
- RELEASE_VERSION=${RELEASE_TAG#v}
86
-
87
- echo "Package version: $PACKAGE_VERSION"
88
- echo "Release version: $RELEASE_VERSION"
89
-
90
- if [ "$PACKAGE_VERSION" != "$RELEASE_VERSION" ]; then
91
- echo "Error: Package version ($PACKAGE_VERSION) does not match release tag ($RELEASE_VERSION)"
92
- exit 1
93
- fi
94
-
95
- - name: Publish to npm with provenance
96
- run: npm publish --provenance --access public
97
- env:
98
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CLAUDE.md DELETED
@@ -1,101 +0,0 @@
1
- # CLAUDE.md
2
-
3
- Guidance for AI coding assistants working on **koa-classic-server**.
4
-
5
- ---
6
-
7
- ## Project orientation
8
-
9
- koa-classic-server is a Koa middleware that serves static files from disk over HTTP, with Apache2-like directory listings, optional template-engine integration, and server-side compressed cache. It is a *classic* file server — its primary job is to take an HTTP request and respond with the file at the requested path, or with a directory listing if a directory is requested without an index file.
10
-
11
- The project is **not** a framework, not a router, not a CMS. It is intentionally focused.
12
-
13
- ---
14
-
15
- ## Design philosophy: HTTP file server first
16
-
17
- The middleware's primary contract with the operator is:
18
-
19
- > **"If a file exists in the served directory, `GET` on its path returns it. If a directory is requested without an index file, the listing shows every visible entry."**
20
-
21
- This contract drives every default. The defaults are picked so that:
22
-
23
- - Asking for any file under `rootDir` returns it (no silent 404 unless the file truly does not exist).
24
- - Asking for a directory without an index file returns the listing of that directory.
25
- - The listing includes every visible entry.
26
- - No request is silently restricted by some default policy the operator did not ask for.
27
-
28
- In short: **the operator's directory is the source of truth. The middleware does not second-guess it.**
29
-
30
- ### What this implies for defaults
31
-
32
- - **Dot-files are visible by default.** Files named `.env`, `.htaccess`, `.well-known/...` are served if requested. If the operator does not want this, they hide them via the `hidden.dotFiles` namespace.
33
- - **No artificial small-entry limit on directory listings.** If a directory has 5,000 files, the listing shows 5,000 entries. The middleware does NOT decide that "5,000 is too many".
34
- - **No forced pagination on tiny directories.** Pagination kicks in only when the listing exceeds `dirListing.entriesPerPage`. The default is high enough that most directories render in a single page.
35
-
36
- ### What counts as a "safety net" (acceptable)
37
-
38
- Some defaults are NOT restrictions on the served content — they are guards against catastrophic failure modes of the **process itself**:
39
-
40
- | Default | Protects against |
41
- |---|---|
42
- | `template.renderTimeout: 30000` | Hung template render blocking the event loop indefinitely |
43
- | `serverCache.compressedFile.maxSize: 100 MB` | RAM growing unbounded in the compressed-response cache |
44
- | `dirListing.maxEntries: 100000` | OOM at `readdir()` allocation time on accidentally-huge directories (broken log rotation, mistakenly mounted FS) |
45
-
46
- These are deliberate exceptions because they protect the process from itself, not the served content. The distinction:
47
-
48
- - A **safety net** prevents the server from crashing.
49
- - A **restriction** prevents the operator's intent from being respected.
50
-
51
- ### What restrictions look like (and would NOT be acceptable as defaults)
52
-
53
- - Hiding files by name pattern (`.env`, `.git`, `secret*`) without the operator opting in.
54
- - Refusing to serve files larger than N bytes by default.
55
- - Auto-disabling listings on "too many" entries.
56
- - Forcing small-default pagination on the listing UI.
57
-
58
- When proposing a new feature, ask: *"does this change the default observable behavior of `GET /path/to/file` or `GET /some/dir/`?"* If yes, it is a restriction — make it opt-in.
59
-
60
- > Note: `method: ['GET']` IS technically restrictive (rejects HEAD, POST, etc. by default). It is kept as-is because it has been the v2 default since forever and the migration cost is not worth the philosophical purity. Documented as a known imperfection.
61
-
62
- ---
63
-
64
- ## Consequences for future changes
65
-
66
- - **New options should default to "transparent / pass-through".** A new feature that changes default observable behavior must be defended in the PR description: why is this a safety net and not a restriction?
67
-
68
- - **Security hardening lives in documentation, not in defaults.** When you find a hardening opportunity, the first instinct should be to add a row to the *Security Checklist* in `README.md` and `docs/DOCUMENTATION.md`, not to change a default. Defaults serve operators; the checklist guides them when they need to harden.
69
-
70
- - **Breaking-change cost is real.** This middleware has v2-era stable options. Renaming or changing default behavior of stable options breaks every operator on upgrade. Justify breaks by **structural necessity**, not by aesthetic preference. Renaming `showDirContents` → `dirListing.enabled` was justified because it was needed to group related listing options under a namespace. Renaming `hideExtension.redirect` → `redirectStatusCode` would be aesthetic only and was therefore declined.
71
-
72
- - **Aliases for v2-stable names are acceptable** to soften transitions, with a one-time deprecation warning via `_logger.warn(...)` (see the `showDirContents` alias for the canonical pattern).
73
-
74
- - **Throw guards for V3-alpha-only options** are acceptable as hard breaks (no v2 user has them; alpha-testers accept breakage).
75
-
76
- ---
77
-
78
- ## Key references
79
-
80
- - **`README.md`** — user-facing entry point. Contains Security Checklist and Suggested Security Configuration sections.
81
- - **`docs/DOCUMENTATION.md`** — full API reference and Best Practices guide.
82
- - **`docs/CHANGELOG.md`** — version history; breaking changes documented under *⚠️ Breaking Changes*.
83
- - **`docs/security_improvement_for_V3.md`** — audit roadmap for v3 security improvements (implemented + Future Work under `[F-1]`).
84
- - **`__tests__/`** — 543+ tests asserting behavior contracts. Run with `npm test`.
85
-
86
- ---
87
-
88
- ## Working conventions
89
-
90
- - All defaults are documented in the JSDoc-style block at the top of the factory function in `index.cjs` (~line 480). When you change a default, update that block.
91
- - Validation errors throw at factory time with a helpful migration hint. See existing throw guards for `cacheMaxAge`, `enableCaching`, `maxDirEntries`, `pageSize`, `compression.minSize`.
92
- - Tests use `supertest` over a `Koa` app instantiated per `describe` block.
93
- - The CSP hash for the directory-listing inline CSS is computed once at module load (`_listingCssHash`) — editing the listing CSS automatically refreshes the hash. Tests that asserted the hash must compute it from the actual `<style>` block in the response, not hardcode it.
94
- - Once-per-process warnings use a module-level boolean flag (see `_showDirContentsDeprecationWarned` for the canonical pattern).
95
- - Logger calls use `warnPayload(_logger, msg)` so that structured loggers (pino/winston) receive plain text and `console` receives ANSI colors.
96
-
97
- ---
98
-
99
- ## When in doubt
100
-
101
- Re-read the **Design philosophy** section above. If the change you are about to propose would make `GET /some/file` behave differently than the operator placing that file would expect, you are probably violating the philosophy. Either redesign the change as opt-in, or document the rationale explicitly in the PR.
@@ -1,354 +0,0 @@
1
-
2
- > koa-classic-server@1.2.0 test:performance
3
- > jest __tests__/performance.test.js --runInBand
4
-
5
- console.log
6
-
7
- 📊 Small File (1KB) Benchmark:
8
-
9
- at Object.log (__tests__/performance.test.js:90:21)
10
-
11
- console.log
12
- Average: 2.93ms
13
-
14
- at Object.log (__tests__/performance.test.js:91:21)
15
-
16
- console.log
17
- Median: 2.54ms
18
-
19
- at Object.log (__tests__/performance.test.js:92:21)
20
-
21
- console.log
22
- Min: 1.99ms
23
-
24
- at Object.log (__tests__/performance.test.js:93:21)
25
-
26
- console.log
27
- Max: 26.87ms
28
-
29
- at Object.log (__tests__/performance.test.js:94:21)
30
-
31
- console.log
32
-
33
- 📊 Medium File (100KB) Benchmark:
34
-
35
- at Object.log (__tests__/performance.test.js:109:21)
36
-
37
- console.log
38
- Average: 3.59ms
39
-
40
- at Object.log (__tests__/performance.test.js:110:21)
41
-
42
- console.log
43
- Median: 3.51ms
44
-
45
- at Object.log (__tests__/performance.test.js:111:21)
46
-
47
- console.log
48
- Min: 2.46ms
49
-
50
- at Object.log (__tests__/performance.test.js:112:21)
51
-
52
- console.log
53
- Max: 8.36ms
54
-
55
- at Object.log (__tests__/performance.test.js:113:21)
56
-
57
- console.log
58
-
59
- 📊 Large File (1MB) Benchmark:
60
-
61
- at Object.log (__tests__/performance.test.js:128:21)
62
-
63
- console.log
64
- Average: 9.03ms
65
-
66
- at Object.log (__tests__/performance.test.js:129:21)
67
-
68
- console.log
69
- Median: 8.35ms
70
-
71
- at Object.log (__tests__/performance.test.js:130:21)
72
-
73
- console.log
74
- Min: 5.46ms
75
-
76
- at Object.log (__tests__/performance.test.js:131:21)
77
-
78
- console.log
79
- Max: 13.81ms
80
-
81
- at Object.log (__tests__/performance.test.js:132:21)
82
-
83
- console.log
84
-
85
- 📊 Small Directory (100 files) Benchmark:
86
-
87
- at Object.log (__tests__/performance.test.js:150:21)
88
-
89
- console.log
90
- Average: 2.65ms
91
-
92
- at Object.log (__tests__/performance.test.js:151:21)
93
-
94
- console.log
95
- Median: 2.54ms
96
-
97
- at Object.log (__tests__/performance.test.js:152:21)
98
-
99
- console.log
100
- Min: 2.22ms
101
-
102
- at Object.log (__tests__/performance.test.js:153:21)
103
-
104
- console.log
105
- Max: 4.69ms
106
-
107
- at Object.log (__tests__/performance.test.js:154:21)
108
-
109
- console.log
110
-
111
- 📊 Large Directory (1,000 files) Benchmark:
112
-
113
- at Object.log (__tests__/performance.test.js:168:21)
114
-
115
- console.log
116
- Average: 9.23ms
117
-
118
- at Object.log (__tests__/performance.test.js:169:21)
119
-
120
- console.log
121
- Median: 9.14ms
122
-
123
- at Object.log (__tests__/performance.test.js:170:21)
124
-
125
- console.log
126
- Min: 8.26ms
127
-
128
- at Object.log (__tests__/performance.test.js:171:21)
129
-
130
- console.log
131
- Max: 11.64ms
132
-
133
- at Object.log (__tests__/performance.test.js:172:21)
134
-
135
- console.log
136
- ⚠️ WARNING: This will be MUCH faster after async optimization
137
-
138
- at Object.log (__tests__/performance.test.js:175:21)
139
-
140
- console.log
141
-
142
- 📊 Very Large Directory (10,000 files) Benchmark:
143
-
144
- at Object.log (__tests__/performance.test.js:189:21)
145
-
146
- console.log
147
- Average: 102.37ms
148
-
149
- at Object.log (__tests__/performance.test.js:190:21)
150
-
151
- console.log
152
- Median: 95.13ms
153
-
154
- at Object.log (__tests__/performance.test.js:191:21)
155
-
156
- console.log
157
- Min: 90.91ms
158
-
159
- at Object.log (__tests__/performance.test.js:192:21)
160
-
161
- console.log
162
- Max: 120.85ms
163
-
164
- at Object.log (__tests__/performance.test.js:193:21)
165
-
166
- console.log
167
- ⚠️ WARNING: Event loop BLOCKED during this operation!
168
-
169
- at Object.log (__tests__/performance.test.js:194:21)
170
-
171
- console.log
172
- ⚠️ Expected to drop to ~30.71ms after optimization
173
-
174
- at Object.log (__tests__/performance.test.js:195:21)
175
-
176
- console.log
177
-
178
- 📊 10 Concurrent Small Files:
179
-
180
- at Object.log (__tests__/performance.test.js:212:21)
181
-
182
- console.log
183
- Total time: 15.50ms
184
-
185
- at Object.log (__tests__/performance.test.js:213:21)
186
-
187
- console.log
188
- Avg per request: 1.55ms
189
-
190
- at Object.log (__tests__/performance.test.js:214:21)
191
-
192
- console.log
193
-
194
- 📊 5 Concurrent Directory Listings (100 files):
195
-
196
- at Object.log (__tests__/performance.test.js:231:21)
197
-
198
- console.log
199
- Total time: 11.30ms
200
-
201
- at Object.log (__tests__/performance.test.js:232:21)
202
-
203
- console.log
204
- Avg per request: 2.26ms
205
-
206
- at Object.log (__tests__/performance.test.js:233:21)
207
-
208
- console.log
209
- ⚠️ With current sync code, these run SEQUENTIALLY
210
-
211
- at Object.log (__tests__/performance.test.js:234:21)
212
-
213
- console.log
214
- ⚠️ After async optimization, will run in PARALLEL
215
-
216
- at Object.log (__tests__/performance.test.js:235:21)
217
-
218
- console.log
219
-
220
- 📊 404 Not Found Benchmark:
221
-
222
- at Object.log (__tests__/performance.test.js:252:21)
223
-
224
- console.log
225
- Average: 1.26ms
226
-
227
- at Object.log (__tests__/performance.test.js:253:21)
228
-
229
- console.log
230
- Median: 1.24ms
231
-
232
- at Object.log (__tests__/performance.test.js:254:21)
233
-
234
- console.log
235
- Min: 1.05ms
236
-
237
- at Object.log (__tests__/performance.test.js:255:21)
238
-
239
- console.log
240
- Max: 2.17ms
241
-
242
- at Object.log (__tests__/performance.test.js:256:21)
243
-
244
- console.log
245
-
246
- 📊 Memory Usage (10,000 files directory):
247
-
248
- at Object.log (__tests__/performance.test.js:278:21)
249
-
250
- console.log
251
- Heap used increase: 1.16 MB
252
-
253
- at Object.log (__tests__/performance.test.js:279:21)
254
-
255
- console.log
256
- External increase: 2.57 MB
257
-
258
- at Object.log (__tests__/performance.test.js:280:21)
259
-
260
- console.log
261
- Response size: 1.29 MB
262
-
263
- at Object.log (__tests__/performance.test.js:281:21)
264
-
265
- console.log
266
- ⚠️ Expected to reduce by ~30-40% after optimization
267
-
268
- at Object.log (__tests__/performance.test.js:282:21)
269
-
270
- console.log
271
-
272
- ======================================================================
273
-
274
- at Object.log (__tests__/performance.test.js:289:13)
275
-
276
- console.log
277
- 📋 BASELINE BENCHMARK SUMMARY
278
-
279
- at Object.log (__tests__/performance.test.js:290:13)
280
-
281
- console.log
282
- ======================================================================
283
-
284
- at Object.log (__tests__/performance.test.js:291:13)
285
-
286
- console.log
287
-
288
- These results represent the CURRENT performance (v1.2.0)
289
-
290
- at Object.log (__tests__/performance.test.js:292:13)
291
-
292
- console.log
293
- After implementing optimizations, run this test again to see improvements.
294
-
295
- at Object.log (__tests__/performance.test.js:293:13)
296
-
297
- console.log
298
- Expected improvements after optimization:
299
-
300
- at Object.log (__tests__/performance.test.js:294:13)
301
-
302
- console.log
303
- ✓ Small files: 10-20% faster (async operations)
304
-
305
- at Object.log (__tests__/performance.test.js:295:13)
306
-
307
- console.log
308
- ✓ Large directories: 50-70% faster (async + array join)
309
-
310
- at Object.log (__tests__/performance.test.js:296:13)
311
-
312
- console.log
313
- ✓ Concurrent requests: 5-10x faster (non-blocking event loop)
314
-
315
- at Object.log (__tests__/performance.test.js:297:13)
316
-
317
- console.log
318
- ✓ Memory usage: 30-40% reduction (array join vs concatenation)
319
-
320
- at Object.log (__tests__/performance.test.js:298:13)
321
-
322
- console.log
323
- ✓ With HTTP caching: 80-95% faster (304 responses)
324
-
325
- at Object.log (__tests__/performance.test.js:299:13)
326
-
327
- console.log
328
- ======================================================================
329
-
330
- at Object.log (__tests__/performance.test.js:300:13)
331
-
332
- PASS __tests__/performance.test.js
333
- Performance Benchmarks - BASELINE (v1.2.0)
334
- File Serving Performance
335
- ✓ Benchmark: Small file (1KB) - 100 iterations (318 ms)
336
- ✓ Benchmark: Medium file (100KB) - 50 iterations (184 ms)
337
- ✓ Benchmark: Large file (1MB) - 20 iterations (183 ms)
338
- Directory Listing Performance
339
- ✓ Benchmark: Small directory (100 files) - 50 iterations (135 ms)
340
- ✓ Benchmark: Large directory (1,000 files) - 20 iterations (188 ms)
341
- ✓ Benchmark: Very large directory (10,000 files) - 5 iterations (515 ms)
342
- Concurrent Request Performance
343
- ✓ Benchmark: 10 concurrent small file requests (18 ms)
344
- ✓ Benchmark: 5 concurrent directory listings (100 files each) (14 ms)
345
- 404 Not Found Performance
346
- ✓ Benchmark: Non-existent file - 50 iterations (66 ms)
347
- Memory Usage (Informational)
348
- ✓ Memory usage during large directory listing (88 ms)
349
-
350
- Test Suites: 1 passed, 1 total
351
- Tests: 10 passed, 10 total
352
- Snapshots: 0 total
353
- Time: 3.227 s, estimated 4 s
354
- Ran all test suites matching /__tests__\/performance.test.js/i.