Created
November 12, 2018 14:09
-
-
Save thejones/dab4976d89cf2f9ba9204e9663e570f6 to your computer and use it in GitHub Desktop.
Save express routes to file (express-list-endpoints)
This file contains 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
const listEndpoints = require('express-list-endpoints') | |
var app = express(); | |
//express setup | |
//then list them | |
// This is quick and dirty (no error probably cannot be run more than once correctly) | |
fs.mkdir(__dirname + "/tmp/", { recursive: true }, (err) => { | |
fs.writeFile(__dirname + "/tmp/routes.json", JSON.stringify(listEndpoints(app), null, 2), { flag: 'wx' }, function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log("The file was saved!"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment