Closed KaKi87 closed 2 years ago
You can inspect the existing routes in the routing table by looking at server.router
. In particular, the router has a routes
property and a lookup()
method.
So, for example, you could do something like this:
const route = server.router.lookup('GET', '/');
const hasHandler = Boolean(route?.handler);
Admittedly, the documentation for those APIs is a bit sparse. PRs welcome to expand upon it.
Very cool, thanks for sharing your usage of it.
By the way, I'm working on #62 and those changes will likely fix your bug #66 at the same time. Let me know if you have any other suggestions, as I'm planning a new release soon.
Alright !
Well, I implemented everything I needed to automate in this route.js
file :
error
event that could be globally listened to, like server.on('error', callback)
).One last thing I'm missing is Sentry (or alternative) integration but that's up to them (getsentry/sentry-javascript#3009).
Oh and I needed BasicAuth too.
Hello,
Is it possible to programmatically check if an handler already exists for a specific route ?
Thanks