README
Minimalist ACL
Minimalistic ACL implementation for privileges management in javascript
Installation
$ npm i minimalist-acl --save
or
$ yarn add minimalist-acl --save
Usage
// using ES modules
import { check } from "minimalist-acl";
// using CommonJS modules
const { check } = require("minimalist-acl");
const user = {
get roles() {
return ["moderator"];
},
};
const can = check("administrator || moderator", (role) => {
return user.roles.includes(role);
});
if (!can) {
throw new Error("You not allowed to this resource.");
}
Syntax
and (&&)
- administrator && moderator
or (||)
- administrator || moderator
not (!)
- administrator && !moderator
Support
Having a problem? Open an issue I will be happy to help you.
License
The MIT License (MIT). Please see License File for more information.