Release notes for new releases are in GitHub releases.
BREAKING CHANGES
- Requires TypeScript 4.1 or newer
- Remove dhe deprecated
routeHandler()
,run()
,Parser.routeParams()
andParser.routeParamsP()
functions. - Remvove the deprecated function chaining syntax for defining routes
- Remove
URL.int()
andURL.str()
in favor of path patterns and conversions
New features
- Type-safe support for path patterns like
'/user/:id(num)/foo/:bar(custom)'
- Support for registering custom route parameter conversions with
route.useParamConversions()
BREAKING CHANGES
-
Middleware functions now receive a typera request object as an argument.
Upgrade your typera-koa middleware like this:
// OLD const myMiddleware: Middleware<...> = (ctx) => { doSomething(ctx) // ... } // NEW const myMiddleware: Middleware<...> = (req) => { doSomething(req.ctx) // ... }
typera-express middleware are not affected, as their argument already was a
{ req, res }
object. -
typera-express exported
ExpressContext
was renamed toRequestBase
.
Deprecations
- The previous syntax for defining routes is now deprecated:
route(method, path)(middleware)(async request => { ... })
New features
- Export the
RequestBase
type from typera-express and typera-koa - Add
ChainedMiddleware
to use results from previous middleware - Add a new syntax for defining routes:
route(method, path).use(middleware).handler(async request => { ... })
Fixes
- Middleware: Allow running a finalizer without adding anything to the request
object by returning
Middleware.next(undefined, f)
(#25)
Dependencies
- typera-express: Remove peerDependencies, depend directly on express
- typera-koa: Remove peerDependencies, depend directly on koa utility libraries
- Use @koa/router instead of the unmaintained koa-router
Fixes
- Make the
Middleware
type more lenient about the result type. Usingunknown
is preferred if the middleware doesn't add anything to the request.
Fixes
- Fix URL parsing when there are multiple captures
New features
- Add
Response.redirect()
- Add support for streaming responses
Fixes
typera-express
: Catch promise rejections and forward the errors down the middleware chain
New features
- Add
route.get()
,.post()
,.put()
,.delete()
,.head()
,.options()
,.patch()
,.all()
. - Add
route.use()
- Make modules importable from
typera-*/name
, e.g.typera-koa/response
.
Breaking change
- Middleware return type changed from
Either
to another type. UseMiddleware.next()
to return a result andMiddleware.stop()
to return a response from a middleware function.
New features
- Add
Middleware.next(value[, finalizer])
andMiddleware.stop(response)
- Add
applyMiddleware(...middleware)
- Add 5xx responses to the
Response
namespace
Other
typera-express
: Change express dependecy to a peerDependencytypera-koa
: Change koa and koa-boadyparser dependecies to peerDependenciestypera-koa
: Don't depend on koa-router anymore
New features
- Add support for middleware
- Add
router()
androute()
Deprecations
- Deprecate
routeHandler()
andrun()
in favor ofrouter()
androute()
.
Breaking Change
- Upgrade
fp-ts
to^2.0.0