Skip to content

Instantly share code, notes, and snippets.

@iddar
Created August 29, 2019 13:53
Show Gist options
  • Save iddar/be43ab8dfce85076644a28c160132bff to your computer and use it in GitHub Desktop.
Save iddar/be43ab8dfce85076644a28c160132bff to your computer and use it in GitHub Desktop.
export express routes
function getTrue(obj) {
return Object.keys(obj).filter(el => obj[el])
}
const fs = require('fs')
const stream = fs.createWriteStream("routes_file.txt")
stream.once('open', function(fd) {
api.stack.forEach(function(r){
if (r.route && r.route.path){
let line = `[${getTrue(r.route.methods).join(',')}]: ${r.route.path}`
stream.write(line + '\n')
console.log(line)
}
})
stream.end();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment