1.2.0 • Published 8 years ago

level-routes v1.2.0

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

Level Routes

Express route helper that allows you to setup dynamic route files that are auto loaded. Also allows for user permissions.

Usage

app.use('/', require('level-routes')( { route_directory: __dirname + '/routes', level_key: 'level_id', denied: function(res, req, next) {} levels: { user: 1, admin: 2, } } ))

Options

route_directory

The path to the directory that holds your routes

level_key

The key to use to access the user permission level. This is used to check the request object of the route. ex. reqlevel_key = 1.

denied

The callback function that will run when permission is denied. Suggested to either redirect or throw a 401 error.

levels

The levels for user permission. The keys of this object are the folder names in which the routes live. The value is the String, Number or Array of the level permissions allowed to access that route.