feat(typedrouter): add middleware support to TypedRouter and export middleware type

This commit is contained in:
2026-03-03 20:22:01 +00:00
parent a1f5916faf
commit ee820dd126
11 changed files with 1187 additions and 453 deletions

View File

@@ -1,5 +1,17 @@
# Changelog
## 2026-03-03 - 3.3.0 - feat(typedrouter)
add middleware support to TypedRouter and export middleware type
- Introduces TMiddlewareFunction and TypedRouter.addMiddleware() to run pre-handler middleware (throw TypedResponseError to reject).
- Adds getTypedHandlerAndRouter() to determine owning router so middleware runs on the correct router.
- Middleware errors are converted into response errors, encoded for network, and outgoing hooks are called; request short-circuits if middleware rejects.
- TypedRouter is now generic (TReqConstraint) and several internal references updated to TypedRouter<any> for compatibility.
- Exports TMiddlewareFunction from index.ts so consumers may reference middleware types.
- Documentation (readme) updated with middleware usage and guidance.
- Tests updated: browser test replaced/renamed to chromium, server tests updated to use TypedServer. Data handling in test adjusted to support Buffer/Uint8Array and serialized Buffer shapes.
- package.json: devDependencies and some deps bumped; build script simplified (removed legacy flags).
## 2026-03-01 - 3.2.7 - fix(virtualstream)
reconstitute JSON-serialized binary data in VirtualStream; update docs, build config, and dependency bumps