-
-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Labels
Description
Is there a way of determining if an exact route exists and running some code if it doesn't. For example:
const Router = require('router')
const route = Router().use('/some/route', (res, req, next) => next())
route({url: '/some/nonexistent/route', method: 'get'}, {}, err => {
if (err && err instanceof NoRouteError) {
console.log('No route match')
}
})
Or perhaps something like:
const Router = require('router')
const route = Router().use('/some/route', (res, req, next) => next())
const routeExists = route.test({url: '/some/nonexistent/route', method: 'get'})
console.log(routeExists ? 'ok' : 'No route match')
I'm currently using the library without any HTTP server, just as a router and middleware engine. So req.send()
doesn't exist for me (and shouldn't), I simply call next()
until there is no more middleware in the stack.
Any direction on this would be great.