Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created May 5, 2015 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/e336cb078bebdf6ba6eb to your computer and use it in GitHub Desktop.
Save mattpodwysocki/e336cb078bebdf6ba6eb to your computer and use it in GitHub Desktop.
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