Created
August 29, 2019 13:53
-
-
Save iddar/be43ab8dfce85076644a28c160132bff to your computer and use it in GitHub Desktop.
export express routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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