{"id":18092,"library":"acl","title":"acl","description":"ACL (Access Control List) library for Node.js, version 0.4.11, last updated in 2019. Provides role-based permission management with support for Redis, MongoDB, and in-memory backends. Includes Express middleware for protecting routes. Compared to alternatives like accesscontrol or casl, acl is older and more minimalistic, with a callback/promise API and limited TypeScript support. The package is in maintenance mode; no active development.","status":"maintenance","version":"0.4.11","language":"javascript","source_language":"en","source_url":"git://github.com/optimalbits/node_acl","tags":["javascript","middleware","acl","web"],"install":[{"cmd":"npm install acl","lang":"bash","label":"npm"},{"cmd":"yarn add acl","lang":"bash","label":"yarn"},{"cmd":"pnpm add acl","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required if using Redis backend","package":"redis","optional":true},{"reason":"Required if using MongoDB backend","package":"mongodb","optional":true}],"imports":[{"note":"Package is CommonJS only; no default ESM export.","wrong":"import acl from 'acl'","symbol":"acl","correct":"const acl = require('acl')"},{"note":"acl must be instantiated with a backend instance.","wrong":"const acl = new acl.redisBackend()","symbol":"new acl()","correct":"const acl = new acl(new acl.redisBackend(redisClient))"},{"note":"middleware() returns a function; must be called with () even without options.","wrong":"app.use(acl.middleware)","symbol":"acl.middleware","correct":"app.use(acl.middleware())"}],"quickstart":{"code":"const acl = require('acl');\nconst redis = require('redis');\nconst client = redis.createClient();\nconst aclInstance = new acl(new acl.redisBackend(client));\naclInstance.allow('admin', 'blogs', '*');\naclInstance.addUserRoles('john', 'admin');\naclInstance.isAllowed('john', 'blogs', 'delete', (err, allowed) => {\n  console.log('Allowed:', allowed); // true\n});","lang":"javascript","description":"Creates an ACL instance with Redis backend, allows admin full access to blogs, assigns user 'john' as admin, and checks if john can delete blogs."},"warnings":[{"fix":"Use acl.allow('admin', '*', '*') to grant all permissions on all resources, or list all resources explicitly.","message":"acl.allow() with wildcard '*' does not grant permissions on resources that are not explicitly listed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use promises or callbacks; do not attempt method chaining.","message":"The library does not chain methods; each call returns a promise (or calls callback).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Omit callback parameter and use .then().catch() or async/await.","message":"Callbacks are deprecated; use promises instead.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Ensure redisClient is connected before instantiating ACL.","message":"Redis backend requires a connected client; passing an unconnected client will cause errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass option object with 'role' and 'resource' or use acl.middleware(3, 'user', 'username') for dynamic roles.","message":"middleware() with no parameters restricts all routes; you must specify resource and permissions options.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use a different variable name for the instance, e.g., const aclInstance = new acl(new acl.redisBackend(client)); aclInstance.allow(...).","cause":"The variable acl shadows the module import. You used 'new acl()' and then tried to call acl.allow(). After instantiating, the 'acl' variable refers to the instance, not the module.","error":"TypeError: acl.allow is not a function"},{"fix":"Start Redis server with 'redis-server' or provide correct host/port in redis.createClient().","cause":"Redis server is not running or not accessible.","error":"Error: Redis connection to 127.0.0.1:6379 failed"},{"fix":"Run 'npm install acl' in your project directory.","cause":"Package not installed.","error":"Cannot find module 'acl'"},{"fix":"Use app.use(acl.middleware()) instead of app.use(acl.middleware).","cause":"Attempted to use acl.middleware directly as a middleware instead of calling it.","error":"acl.middleware is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}