feat: v1.0.7 — Security middleware, Express parity, 97%+ API compatibility#26
Merged
ShayanHussainSB merged 33 commits intomainfrom Mar 10, 2026
Merged
feat: v1.0.7 — Security middleware, Express parity, 97%+ API compatibility#26ShayanHussainSB merged 33 commits intomainfrom
ShayanHussainSB merged 33 commits intomainfrom
Conversation
…ngs/Languages, chaining, download callback, attachment, and end encoding
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ry type narrowing
builtbyali
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The biggest release since 1.0. This PR ships three security middleware, a complete Express API parity rewrite, and brings bunWay to 97%+ Express 4.x compatibility — verified by 1,662 tests with zero failures.
What's in this PR
29 commits across 44 files — 5,202 lines added, 431 removed.
Security & Protection Middleware (3 new)
timeout(ms, options?)— Request Timeoutreq.timedoutboolean flag for async handler awarenessskipfunction to exempt specific requests (e.g., file uploads)respond: falsemode for manual timeout handlingconnect-timeoutcompatiblehpp(options?)— HTTP Parameter Pollution Protectionwhitelistoption to allow arrays for specific paramsreq.queryPollutedhpppackage compatiblevalidate(schema, options?)— Request Validationbody,query, andparamsrequired,isEmail,isInt,isLength,matches,isIn,isURL,isUUID,isISO8601,customabortEarly,statusCode,errorFormatter,onErrorexpress-validatorcompatible patternsExpress Parity (15 improvements)
Content Negotiation — RFC 7231 Compliant
req.accepts()— rewritten with quality-value parsing (replaces substring matching)req.acceptsCharsets(),req.acceptsEncodings(),req.acceptsLanguages()— full quality-value support with language range matching (enmatchesen-US)req.is()— proper MIME type matching with wildcard support (text/*,*/json)src/utils/content-negotiation.tsengine — replaces theaccepts+type-isnpm packagesResponse Enhancements
res.send()auto-detection — string→text/html, object→application/json, buffer→application/octet-stream(Express behavior)res.send()andres.json()now returnthisfor chainingres.sendFile()callback —res.sendFile(path, [options], callback)res.sendFile()extended options —lastModified,cacheControl,immutable,acceptRangesres.download()callback —res.download(path, [filename], [options], callback)res.attachment()Content-Type — auto-detects from filename extensionres.end()encoding + callback —res.end(data, encoding, callback)Routing Enhancements
app.get(/\/users\/(?<id>\d+)/, handler)with named capture groups*routes —app.all("*", handler)normalized to match all pathsapp.mountpath— property set when sub-app is mountedapp.path()— returns canonical path for nested mountsRequest Enhancements
req.param('name')— now checks params → body → query (Express parity)Testing
276 new tests across:
New test files
tests/unit/utils/content-negotiation.spec.ts— 30 tests for RFC 7231 parsingtests/unit/core/request-negotiation.spec.ts— 17 tests for accepts/is/paramtests/unit/core/response-send.spec.ts— 15 tests for send auto-detect + chainingtests/unit/core/response-sendfile.spec.ts— 16 tests for sendFile/download/attachmenttests/unit/core/router-regex.spec.ts— 44 tests for regex routes + catch-alltests/unit/core/app-mountpath.spec.ts— 4 tests for mountpath/path()tests/unit/middleware/timeout.spec.ts— 12 teststests/unit/middleware/hpp.spec.ts— 12 teststests/unit/middleware/validation.spec.ts— 30 teststests/integration/middleware/timeout.test.ts— HTTP round-trip timeout teststests/integration/middleware/hpp.test.ts— HTTP round-trip HPP teststests/integration/middleware/validation.test.ts— HTTP round-trip validation teststests/integration/response/send-autodetect.test.ts— Content-Type auto-detectiontests/integration/routing/regex-routes.test.ts— Regex route matchingtests/acceptance/phase3.spec.ts— End-to-end security middlewaretests/express-compat/phase3.spec.ts— Express behavior parity (middleware)tests/express-compat/phase4.spec.ts— Express behavior parity (API surface)Documentation
src/README.md) — before/after import, feature showcaseVersion Bump
package.json: 1.0.6 → 1.0.7VERSION: 1.0.6 → 1.0.7package.jsondescription updated: "97%+ Express parity"package.jsonFiles Changed (44)
Source (8 files)
src/core/request.ts— rewritten accepts/is/param with content negotiationsrc/core/response.ts— send auto-detect, json chaining, sendFile callback/options, download callback, attachment Content-Type, end encodingsrc/core/router.ts— regex routes, catch-all * normalizationsrc/core/fast-matcher.ts— regex route matchingsrc/core/app.ts— mountpath, path()src/index.ts— export timeout, hpp, validatesrc/types.ts— SendFileOptions extendedsrc/utils/content-negotiation.ts— NEW RFC 7231 engineMiddleware (3 new files)
src/middleware/timeout.tssrc/middleware/hpp.tssrc/middleware/validation.tsTests (19 new + 3 modified)
Documentation (11 files)
Test plan
bun test— all 1,662 tests pass, 0 failures