1.0.0 • Published 6 years ago

acler v1.0.0

Weekly downloads
1,102
License
MIT
Repository
-
Last release
6 years ago

ACLer

Minimalistic ACL implementation for privileges management in JS

Installation

$ npm i acler --save

or

$ yarn add acler

Usage

// using ES modules
import { check } from 'acler'
// using CommonJS modules
const { check } = require('acler')

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

Credits

Support

Having trouble? Open an issue!

License

The MIT License (MIT). Please see License File for more information.