Skip to content

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.

npm version

Package Information

Property Value
Package allowaccess
Registry npm
Latest Version npm
Runtime Node.js
Framework Express.js

Resources

Installation

npm install allowaccess@latest

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.