@alanning/roles

A user authorization library, integrates with MongoDB back-end, ported from Meteor accounts.

Stats

StarsIssuesVersionUpdatedCreatedSize
@alanning/roles
1.0.15 years ago5 years agoMinified + gzip package size for @alanning/roles in KB

Readme

roles-npm

A user authorization library, integrates with MongoDB back-end, ported from Meteor accounts.

Based on the Meteor roles package Version 1.2.15.

Usage

import Roles from '@alanning/roles'
import { MongoClient } from 'mongodb'

// MongoDB connection
const db = await MongoClient.connect(MONGO_URL)
// Pass the users and roles collection to the Roles constructor
const roles = new Roles({
    users: db.collection('users')
    roles: db.collection('roles')
})

The roles instance has all the methods documented here.

Build

npm run build

Testing

Start your local MongoDB server:

mongod

Then:

npm test

A roles-npm database will be used during testing. Feel free to delete that database after the tests are run.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.