minimalist-acl-test
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Minimalist ACL

Minimalistic ACL implementation for privileges management in javascript

NPM Version GitHub license

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.

Package Sidebar

Install

npm i minimalist-acl-test

Weekly Downloads

0

Version

0.0.6

License

MIT

Unpacked Size

7.69 kB

Total Files

5

Last publish

Collaborators

  • kledenai