Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v2.0.0 2022-06-24

Compare
Choose a tag to compare
@github-actions github-actions released this 24 Jun 00:20
· 9 commits to master since this release
d74d81d

I am proud to present the new release with new features! While the core concept is still the same, there are big changes on boundaries.

First of all, the router isn't tied to node or http anymore! Although the primary use case is still node's request routing, you can use it for use cases like event processing now. See the example in README.md.

For that reason the mandatory 404 route inside the Router's constructor was removed. Furthermore, built-in matchers are now contract based and don't expect concrete IncomingMessage and ServerResponse instances.

Another big feature is the support of nested routers. This is useful for example for modularization or removing url prefix in a multi-tenant SaaS application.

Breaking changes / migration

// before
const router = new Router((req, res) => send(res, 404))

// after
const router = new NodeHttpRouter()

router.addRoute({
	matcher: new BooleanMatcher(true),
	handler: ({ data: { res } }) => send(res, 404),
})
// before
handler: middlewares(async function myApi(req, res, {
	token,
}) {

// after
handler: middlewares(async function myApi({
	data: {
		req, res, token,
	},
}) {
// before
new ExactQueryMatcher({
	response_type: 'code',

// after
new ExactQueryMatcher({
	response_type: ['code'] as const,

What's Changed