1.2.3 • Published 1 year ago

@acastellon/rest v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.13

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago