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.
Is there a way of determining if an exact route exists and running some code if it doesn't. For example:
Or perhaps something like:
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 callnext()until there is no more middleware in the stack.Any direction on this would be great.