level-routes

1.2.0 • Public • Published

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. req[level_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.

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i level-routes

    Weekly Downloads

    1

    Version

    1.2.0

    License

    ISC

    Last publish

    Collaborators

    • rachelhigley