snaking

1.2.8 • Public • Published

Snaking

Build Status

NPM NPM

The API framework used by ConnektApp, Snaking make you possibe to make a multiple versions API service in a clear way.

Usage

The startup code does keep consistent with express itself as similar as possible as the below shown:

var app = require('snaking');
app.snaking.set('versions', ['v1', 'v2']);
app.listen(9999);

.set(key, val) this function is used to config something that you need to define by your project:

  • versions: accepts an array like ['v2', 'v3'], the property tells Snaking the range of the versions that the router would use later. For example, the v4 in arbitrary router could not be work, calling app.set('versions', ['v4']) is required for this need.

  • prefix: accepts a path, which is to redirect to your routes folder.

  • router: accepts a string, which is the name of file in your route module.

  • session: accepts an object

    • session.secret: String the secret of session
    • session.redis: Object or String, accepts a string like redis://password@host:port/database or an object.
  • acl: accepts an object with the specified schema like the following:

{
  instance: 'in-memory',
  roles: {
    student: ['developer', 'designer'],
    company: {
      admin: true,
      member: ['chat', 'domain']
    }
  },
  allows: [
    ['chat', ['chat'], '*'],
    ['domain', ['domain'], '*']
  ]
}

The instance is supporting three ways for now: in-memory, mongodb and redis. To config a redis instance you should instead the in-memory with the following string:

redis://password@host:6379/db

The password and db is optional.

To describe how your roles would be related, you just define it in roles field. And in allows field, just define how the roles would be working with resources/routers.

After you setup your config, then the project structure looks like the following:

|-index.js
|-{prefix}
      |--moduleA
            |-{router}

.listen(port, server) all of this function follow the same function in express.

Install

$ npm install snaking --save

Test

$ npm test

Example

check example

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i snaking

Weekly Downloads

0

Version

1.2.8

License

MIT

Last publish

Collaborators

  • yorkie