1.2.3 • Published 2 years ago

@acastellon/rest v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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>'

    ,CNAME: '<server.ip-or-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
1.2.3

2 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.13

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22

5 years ago

1.0.23

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago