Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Last active December 20, 2015 10:31
Show Gist options
  • Select an option

  • Save fnakstad/6116325 to your computer and use it in GitHub Desktop.

Select an option

Save fnakstad/6116325 to your computer and use it in GitHub Desktop.
var routes = [
// Partial views
{
path: '/partials/*',
httpMethod: 'GET',
middleware: [function (req, res) {
var requestedView = path.join('./', req.url);
res.render(requestedView);
}]
},
// ... Lots of OAUTH and Local Auth routes here
// User resource
{
path: '/users',
httpMethod: 'GET',
middleware: [ensureAuthorized, UserCtrl.index],
accessLevel: accessLevels.admin
},
// All other get requests should be handled by
// AngularJS's client-side routing system
{
path: '/*',
httpMethod: 'GET',
middleware: [function(req, res) {
var role = userRoles.public, username = '';
if(req.user) {
role = req.user.role;
username = req.user.username;
}
res.cookie('user', JSON.stringify({
'username': username,
'role': role
}));
res.render('index');
}]
}
];
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment