Skip to content

Instantly share code, notes, and snippets.

@scarney81
Last active August 29, 2015 13:58
Show Gist options
  • Save scarney81/9955522 to your computer and use it in GitHub Desktop.
Save scarney81/9955522 to your computer and use it in GitHub Desktop.
Output API routes to console
(function () {
'use strict';
var _ = require('underscore'),
routes = require('./routes'),
log = function (method) {
return function (route) {
console.log(route + ' -- ' + method);
};
},
app = {
get: log('GET'),
post: log('POST'),
put: log('PUT'),
'delete': log('DELETE')
};
function parseRoute(route) {
if (_.isFunction(route)) {
route(app);
} else if (_.isObject(route)) {
_.each(route, parseRoute);
}
}
_.each(routes, parseRoute);
process.exit();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment