function printRoutePaths(router, prefix) { router.stack.forEach(function(r){ if (r.route?.path){ for (let key in r.route.methods) { if (r.route.methods[key]) { console.log(`${key.toUpperCase()} ${prefix}${r.route.path}`) } } } else if (r.name === 'router') { let newPrefix = r.regexp.toString().replace('/^\\', '').replace('\\/?(?=\\/|$)/i', '') printRoutePaths(r.handle, `${prefix}${newPrefix}`) } }) }