npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

drone-acl

v0.1.5

Published

access control list module

Downloads

15

Readme

ACL

An access control list connected to a database via knex module.

How to install

npm install --save drone-acl

How to use

const ACL = require('drone-acl');
const knex = require('knex');

(async function() {
  const knexConn = knex({
    client: 'pg',
    connection: {
      host: '127.0.0.1',
      database: 'database_name',
      user: '',
      password: ''
    },
    migrations: {
      tableName: 'ACL_migrations'
    }
  });

  const acl = new ACL(knexConn);

  // run required database migrations
  await acl.migrate();

  // create a permission
  await acl.permissions.create('view-users', 'Permission to view users');

  // create a role
  const admin = await acl.roles.create('administrator');

  // if role is already created you can use:
  // const admin = acl.role('administrator');

  // assign permissions to a role
  await admin.allow('view-users');

  await admin.hasPermission('view-users'); // true
})();

API

ACL

migrate(): Promise

Create required DB tables

acl.migrate();

role(name: String): RolePermission

Get a role to work with

const role = acl.role('role-name');

RolePermission

allow(permission: String|String[]): Promise

Add a permission or array of permissions to the role access

acl.role('role-name').allow('permission-name');

disallow(permission: String|String[]): Promise

Remove permission or array of permissions from the role access

acl.role('role-name').disallow('permission-name');

hasPermission(permission: String): Promise -> boolean

Verifiy if role has access to the permission

acl.role('role-name').hasPermission('permission-name');

can(permission: String): Promise -> boolean

Alias of hasPermission()

acl.role('role-name').can('permission-name');

Roles

create(name): Promise -> RolePermission

Create a new role

acl.roles.create('role-name-here');

update(name, changes): Promise

Update a role data

acl.roles.update('role-name-here', { name: 'new-role-name' });

delete(name): Promise

Delete a role by its name

acl.roles.delete('role-name-here');

findByName(name): Promise

Find a role by its name

acl.roles.findByName('role-name-here');

list(): Promise

List all available roles

acl.roles.list();

clear(): Promise

Remove all roles

acl.roles.clear();

Permissions

create(name): Promise

Create a new permission

acl.permissions.create('permission name', 'permission description');

update(name, changes): Promise

Update a permission data

acl.permissions.update('role-name-here', {
  name: 'new-permission-name',
  description: 'new-permission description'
});

delete(name): Promise

Delete a permission by its name

acl.permissions.delete('permission-name-here');

findByName(name): Promise

Find a permission by its name

acl.permissions.findByName('permission-name-here');

list(): Promise

List all available permissions

acl.permissions.list();

clear(): Promise

Remove all permissions

acl.permissions.clear();