Created
May 5, 2015 20:24
-
-
Save mattpodwysocki/e336cb078bebdf6ba6eb to your computer and use it in GitHub Desktop.
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
function noop() { } | |
var ThaliAclDb = require('./lib/thaliacldb'); | |
var express = require('express'); | |
var app = express(); | |
var acl = new ThaliAclDb('acl', { db: require('memdown')}); | |
acl.addRole('/guest') | |
.then(function () { | |
acl.addUserToRole('joed', '/guest').then(noop); | |
}); | |
app.get('/:resource', acl.middleware(/* number of / to include in resource */ null, 'joed'), function (req, res) { | |
res.send('joed is allowed'); | |
}); | |
var server = app.listen(3000, function () { | |
var host = server.address().address; | |
var port = server.address().port; | |
console.log('Example app listening at http://%s:%s', host, port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment