Created
November 24, 2016 18:37
-
-
Save DawTaylor/6c00025cc7abe1ca63afe64818d9e175 to your computer and use it in GitHub Desktop.
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
var setRoute = function(file){ | |
var module = require("./controller/" + file) | |
module.map(function(route, index){ | |
routes.set(route.path, route.method, function(req, res, next){ | |
module[index].action(req.params, function(data, code){ | |
res.send(code, data) | |
return next() | |
}) | |
}) | |
}) | |
} | |
fs.readdir('./controller', function(err, files){ | |
files.map(function(file){ | |
setRoute(file) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Não testei, mas refatorei.