@acastellon/rest
REST (HTTPS) based in Express
Last updated 2 months ago by acastellon .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @acastellon/rest 
SYNC missed versions from official npm registry.

REST

Module to encapsulate the common configuration of a base WS based in REST (HTTPS)


Example Code to use this module:

const SERVER = require('./config.server.js');
const AUTH = require('./config.auth.js');
const API = require('./api.js');

const rest = require('@acastellon/rest')(SERVER, AUTH, API);
rest.run(); 

you can pass a function to be executed after the initialization of the server

rest.run(callback())

rest.run(() => { .. })

Example of configuration files required:

- config.server.js

module.exports = {
    /* 
      Switch between HTTP and 
      HTTPS server (it's activated when this parameter is defined 
      indicating where are stored the certificate files) 
    */
    CERTIFICATION_PATH : '/opt/<project>/Certificate'
    
    /* listener port */ 
    ,PORT : 7000
    
    /* file used by CORS to allows requst to the server */
    ,WHITELIST : './whitelist'

    /* location of the static files if is needed */
    ,STATIC_PATH : '/html'         //null = no static files where associated
}

- config.auth.js

module.exports = {
    url: 'ldap://<address>:389'
    ,DOMAIN: '<domain>'
    ,baseDN: 'DC=<>,DC=<>>'
    ,username: '<username>'
    ,password: '<password>'

    ,hostNames: {
        'DEV' : '<dev-server.ip.dns.name>'
        ,'QA' : '<QA-server.ip.dns.name>'
        ,'PROD' : '<production-server.ip.dns.name>'
    }
    ,passToken: '<passphrase-optional>'  /* if doesn't exists the module generates ones automatically */
    ,EXPIRES: 86400                     /* expires in 24 hours */

    , AUTH_TYPE : 'NTLM'  /* NTLM, JWT or NONE */

    ,MOCKUP_USERS : ['acastellon']
    ,MOCKUP_ROLES : ['User','Admin']
    ,ROLES : {                          /* LDAP Roles to match */
        'User': '<LDAP> USER '          
        , 'Admin': '<LDAP> ADMINISTRATOR '
        , 'Viewer': '<LDAP> VIEWER '
    }
}
- api.js
- See the api.template.js as a reference to implement the logic.

Security files required:

- ca.pem
- privateKey.pem
- publicCert.pem
- passphrase

Other files required:

- whitelist : used by CORS

Current Tags

  • 1.0.21                                ...           latest (2 months ago)

22 Versions

  • 1.0.21                                ...           2 months ago
  • 1.0.20                                ...           3 months ago
  • 1.0.19                                ...           5 months ago
  • 1.0.18                                ...           5 months ago
  • 1.0.17                                ...           5 months ago
  • 1.0.16                                ...           5 months ago
  • 1.0.15                                ...           7 months ago
  • 1.0.14                                ...           7 months ago
  • 1.0.13                                ...           8 months ago
  • 1.0.12                                ...           8 months ago
  • 1.0.11                                ...           8 months ago
  • 1.0.10                                ...           8 months ago
  • 1.0.9                                ...           9 months ago
  • 1.0.8                                ...           9 months ago
  • 1.0.7                                ...           9 months ago
  • 1.0.6                                ...           10 months ago
  • 1.0.5                                ...           10 months ago
  • 1.0.4                                ...           10 months ago
  • 1.0.3                                ...           10 months ago
  • 1.0.2                                ...           10 months ago
  • 1.0.1                                ...           10 months ago
  • 1.0.0                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 22
Last Day 0
Last Week 22
Last Month 44
Dependencies (11)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |