apemancode
Code module for apeman.
Last updated 4 years ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install apemancode 
SYNC missed versions from official npm registry.

apemancode

Build Status Code Climate Code Coverage npm Version

Code module for apeman.

Installation

$ npm install apemancode --save

Usage

Create a directory with name "code" and put codes files like "user_roles.json" there.

code/user_roles.json

{
  "ADMIN": 1,
  "STAFF": 2,
  "CUSTOMER": 3
}

code/index.js

"use strict";

const apemancodes = require('apemancodes');

// Exports codes as module.
let codes = apemancodes(__dirname, {
    // Options
});


// Print all codes
codes.print();

module.exports = codes;

Then,

"use strict";

// Require defined codes
const codes = require('./codes/index.js'),
    roles = codes('UserRole');

function isGrunted(person) {
    switch (person.role) {
        case roles.ADMIN:
        case roles.STAFF:
            return true;
        default:
            return false;
    }
}

isGrunted({role: roles.ADMIN});

License

This software is released under the MIT License.

Links

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

1 Versions

  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (9)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |