Created
March 18, 2014 14:56
-
-
Save indiejoseph/9621725 to your computer and use it in GitHub Desktop.
Express 4.x Router index.coffee
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
fs = require 'fs' | |
path = require 'path' | |
router = (require 'express').Router() | |
role = require './role' | |
# acl | |
router.use '/admin*', role.isAuthorized() | |
# load all routers in current folder | |
fs | |
.readdirSync(__dirname) | |
.filter( (file) -> | |
return (file.indexOf('.') isnt 0) && (file isnt 'index.coffee') | |
) | |
.forEach( (file) -> | |
router.use('/admin', (require path.join(__dirname, file))) | |
) | |
module.exports = router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment