Closed Cellaryllis closed 10 months ago
While this is a cool solution, unfortunately it breaks when using routers:
const app = express();
app.get('/route', (req, res) => {
console.log('root route', req.route?.path);
res.send('');
});
const subRotuer = express.Router()
subRotuer.get('/route2', (req, res) => {
console.log('route in router', req.route?.path);
res.send('');
});
app.use('/router', subRotuer)
GET /route GET /router/route2
will log
root route /route
route in router /route2
Unfortunately, I haven't been able to solve this problem
I added a new example for normalizePath as I struggled to get example 2 to work with our routes. Using the routes that are defined in code resulted in the cleanest result for our metrics, especially for our routes that have non-standard id formats in their paths.
Hopefully this example could help save some time for some other users of the package! :)