Socket
Book a DemoInstallSign in
Socket

hapi-relations

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-relations

a relations plugin for hapi

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

hapi-relations

A plugin for hapi using the relations ACL.

Dependencies

relations

See relations for supported clients and ACL structure.

Usage

Pass in your relations schema and choosen client as options.

var Hapi = require('hapi');
var redis = require('redis');
var fs = require('fs');

var client = redis.createClient(6379, 'localhost');
var server = new Hapi.Server();

var schema = JSON.parse(
    fs.readFileSync('schema.json', 'utf8')
);

server.register([
  {
    register: require('hapi-relations'),
    options: {
        schema: schema,
        client: redis,
        clientType: 'redis'
    }
  }
], function (err) {
    console.log(err);
});

Or optionally pass the client in as a server plugin

server.register([
  {
    register: require('hapi-relations'),
    options: {
        schema: schema,
        client: 'hapi-redis',
        clientType: 'redis',
        pluginClient: true
    }
  }
], function (err) {
    console.log(err);
});

And access realtions from the plugins

server.plugins.relations.coins('Can TEST GET from EXAMPLE);

Configuration

The schema expects a loaded schema file, which will be added to relations. A context defines an application in which the user's privileges will be evaulated. For instance, if the context is inventory, then the roles and actions listed within the context correspond to a user's ability to use or add to inventory.

The context consists of roles, and which actions they are allowed to perform. Please see the test/permission.json for an example.

Contributing

Please follow the MRN Javascript Style Guide (forked from AirBnB). Use grunt lint to check yo-self

Keywords

hapi

FAQs

Package last updated on 16 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.