koa-classic-server 2.6.1 → 3.0.0-alpha.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 (40) hide show
  1. package/README.md +68 -10
  2. package/__tests__/caching-headers.test.js +30 -30
  3. package/__tests__/compression-fixtures/data.json +1 -0
  4. package/__tests__/compression-fixtures/large.txt +1 -0
  5. package/__tests__/compression-fixtures/small.txt +1 -0
  6. package/__tests__/compression.test.js +270 -0
  7. package/__tests__/customTest/serversToLoad.util.js +1 -1
  8. package/__tests__/deprecation-warnings.test.js +71 -183
  9. package/__tests__/dt-unknown.test.js +20 -9
  10. package/__tests__/hidden-fixtures/.dot-dir/inside.txt +1 -0
  11. package/__tests__/hidden-fixtures/.env +2 -0
  12. package/__tests__/hidden-fixtures/.well-known/acme-challenge.txt +1 -0
  13. package/__tests__/hidden-fixtures/config/secrets/password.txt +1 -0
  14. package/__tests__/hidden-fixtures/data.key +1 -0
  15. package/__tests__/hidden-fixtures/file.secret +1 -0
  16. package/__tests__/hidden-fixtures/index.html +1 -0
  17. package/__tests__/hidden-fixtures/normal.txt +1 -0
  18. package/__tests__/hidden-fixtures/subdir/.env +1 -0
  19. package/__tests__/hidden-fixtures/subdir/regular.txt +1 -0
  20. package/__tests__/hidden-option.test.js +422 -0
  21. package/__tests__/index-option.test.js +18 -16
  22. package/__tests__/index.test.js +8 -4
  23. package/__tests__/range-fixtures/sample.txt +1 -0
  24. package/__tests__/range.test.js +223 -0
  25. package/__tests__/security-headers.test.js +153 -0
  26. package/__tests__/security.test.js +145 -159
  27. package/__tests__/server-cache-fixtures/large.txt +1 -0
  28. package/__tests__/server-cache-fixtures/small.txt +1 -0
  29. package/__tests__/server-cache.test.js +423 -0
  30. package/__tests__/symlink.test.js +8 -5
  31. package/docs/ACTION_PLAN.md +293 -0
  32. package/docs/CHANGELOG.md +84 -0
  33. package/docs/EXAMPLES_INDEX_OPTION.md +2 -2
  34. package/docs/FLOW_DIAGRAM.md +13 -13
  35. package/docs/OPTIMIZATION_ROADMAP_for_V3.md +864 -0
  36. package/docs/PERFORMANCE_COMPARISON.md +7 -7
  37. package/eslint.config.mjs +17 -0
  38. package/index.cjs +1096 -391
  39. package/index.mjs +1 -5
  40. package/package.json +4 -1
@@ -222,21 +222,21 @@ app.use(koaClassicServer('/public'));
222
222
 
223
223
  // Custom cache duration
224
224
  app.use(koaClassicServer('/public', {
225
- cacheMaxAge: 86400 // 24 hours
225
+ browserCacheMaxAge: 86400 // 24 hours
226
226
  }));
227
227
 
228
228
  // Disable caching (not recommended)
229
229
  app.use(koaClassicServer('/public', {
230
- enableCaching: false
230
+ browserCacheEnabled: false
231
231
  }));
232
232
 
233
233
  // Different strategies for different routes
234
234
  app.use(koaClassicServer('/static-assets', {
235
- cacheMaxAge: 31536000 // 1 year for immutable assets
235
+ browserCacheMaxAge: 31536000 // 1 year for immutable assets
236
236
  }));
237
237
 
238
238
  app.use(koaClassicServer('/dynamic-content', {
239
- cacheMaxAge: 60 // 1 minute for frequently updated content
239
+ browserCacheMaxAge: 60 // 1 minute for frequently updated content
240
240
  }));
241
241
  ```
242
242
 
@@ -320,13 +320,13 @@ app.use(koaClassicServer('/dynamic-content', {
320
320
 
321
321
  2. **No code changes required** - caching is auto-enabled with sensible defaults
322
322
 
323
- 3. **Optional**: Configure `cacheMaxAge` for your use case:
323
+ 3. **Optional**: Configure `browserCacheMaxAge` for your use case:
324
324
  ```javascript
325
325
  // For static assets that rarely change
326
- app.use(koaClassicServer('/assets', { cacheMaxAge: 31536000 }));
326
+ app.use(koaClassicServer('/assets', { browserCacheMaxAge: 31536000 }));
327
327
 
328
328
  // For content that updates frequently
329
- app.use(koaClassicServer('/content', { cacheMaxAge: 300 }));
329
+ app.use(koaClassicServer('/content', { browserCacheMaxAge: 300 }));
330
330
  ```
331
331
 
332
332
  4. **Test caching** in browser DevTools:
@@ -0,0 +1,17 @@
1
+ export default [
2
+ {
3
+ files: ['index.cjs', 'index.mjs'],
4
+ rules: {
5
+ // Enforce strict equality — prevents type coercion bugs.
6
+ // null exception: allows `x == null` as a safe idiom for (x === null || x === undefined).
7
+ 'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
8
+
9
+ // Forbid var — use const/let for block-scoped, predictable declarations.
10
+ 'no-var': 'error',
11
+
12
+ // Flag unused variables — catch dead code and typos in variable names.
13
+ // args: 'after-used' allows unused leading args (e.g. (_, used) callbacks).
14
+ 'no-unused-vars': ['error', { 'vars': 'all', 'args': 'after-used' }],
15
+ },
16
+ },
17
+ ];