AllowAccess
Lightweight Express middleware for role-based route access control.
AllowAccess provides a simple way to control access to Express routes based on user roles. It allows you to define which roles can access specific routes and configure responses for denied requests.
Package Information
| Property | Value |
|---|---|
| Package | allowaccess |
| Registry | npm |
| Latest Version | |
| Runtime | Node.js |
| Framework | Express.js |
Resources
- Source Code: GitLab Repository
- Package Registry: npm
- Documentation: AllowAccess Docs
Installation
Quick Start
import AllowAccess from "allowaccess";
const access = new AllowAccess(401, "You don't have access");
// The role should be populated by your authentication middleware.
router.post("/blog", access.allow(["admin", "author"]), createPost);
AllowAccess reads the user's role from req.body.role.
For advanced usage, configuration, and middleware behavior, see the official documentation.
License
See the source repository for licensing information.