11.0.1 • Published 4 years ago

ut-port-httpserver v11.0.1

Weekly downloads
18
License
Apache-2.0
Repository
github
Last release
4 years ago

HTTP server port

This port exposes the following functionality:

  1. Plain HTTP/HTTPS for static resources
  2. GET/POST requests with JSON-RPC 2.0 body to the /rpc URL
  3. GET/POST requests with JSON body equivalent of the JSON-RPC 2.0 "params" property to the /rpc/namespace/method URL
  4. There are some predefined namespaces and their methods:
  • identity (equivalent to security)
    • identity.login - create a session
    • identity.logout - close a session
    • identity.changePassword - change password
  • permission
    • permission.check - check if a permission for an action is granted
    • permission.list - list permitted actions

Planned features

  1. Secure Remote Password protocol support, as defined in RFC 2945
  2. Multi language support
  3. Fingerprinted resource URLs
  4. WebSockets
  5. Recommendations from http://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication

Planned node modules to be researched

  1. For debugging: https://www.npmjs.com/package/tv
  2. For caching: https://www.npmjs.com/package/catbox
  3. For WebSockets: https://www.npmjs.com/package/shoe

USAGE

Configuration file required options:

    id: '',
    type: 'httpserver',
    logLevel: '',
    port: ''
  • id: unique identification of port

  • logLevel: trace, debug or info.

  • port: the port where the server will accept connections.

  • ports: same as port but sets multiple listening ports

  • server: Server specific configuration

  • fileUpload: File upload configuration

server specific configuration can be passed as object with key server. For instance if we have http server port implementation as follows:

module.exports = {
    id: 'httpserver',
    type: 'httpserver',
    logLevel: 'trace',
    port: 8003,//or use property ports, see below
    ports: [8003, 8004],
    imports:[],
    jwt: { // jwt options (https://github.com/auth0/node-jsonwebtoken)
        verifyOptions: {...}, // options that are used when verifying
        signOptions: {...}, // options that are used when signing
        key: '...' // jwt sign key
    },
    disableXsrf: {http: false, ws: false}, // disable xsrf support for http and ws(web sockets)
    disablePermissionVerify: {ws: false}, // disable verification of services, eg pass requests without checks
    setSecurityHeaders: false, // enable security headers for every request. Usefull when this headers are not set in reverse proxy
    ssoAuthUrl: '...', // to where client should be redirected in order to make single sign on authentication
    appId: 'appName', // required for permission verify in socket-server
    identityNamespace: 'identity', // default value: identity, if identityNamespace is set to false, no identity check will be applied. this is useful when other namespace than identity will be used for identity check
    cookiePaths:'/rpc', // cookie paths, to which paths to bound cookies to, default: /rpc
    fileUpload: {
        maxFileName: 100,
        payloadMaxBytes: 5242880, // 5 MB. Default is 1048576 (1MB)
        extensionsWhiteList: ['pdf', 'doc', 'docx', 'xls', 'txt', 'jpg', 'jpeg', 'png']
    },
    validationPassThrough: (true|false), // if true, validation is not mandatory for methods. default policy: restrictive
    entryPoint: './abc/index.js', // app entry point (webpack helper)
    appId: 'monitoring', // will help when socket server matches permissions.
    server:{
        /*.......*/
    },
    registry: {
        name: 'httpserver007',
        host: '17.0.0.1',
        port: '8030',
        context: {
            key1: 'value1',
            key2: 'value2'
        }
    }
    /*.......*/
};

all properties from server will be passed to server as configuration and will be merged with host and port properties

  • registry this is an optional property instructing how the http server should regiter itself as a service in case service discovery have been enabled for the implementation (for more information about how to enable service discovery on implementation level can be found here. This parameter is entirely optional. If not provided then the following default values will be used:
    {
        name: 'the name of the implementation',
        host: 'the host the http server is started on',
        port: 'the port the http server is started on',
        context: {
            type: 'http'
        }
    }

If only the name needs to be changed from the default input then the following configuration must be passed:

    registry: {
        name: 'custom name'
    }

To disable service registration set

{
    registry: false
}

Optional configuration options:

  • start: function that will be called once on creation of port. It can be used for setting global variables and initializing objects.

Validations (config) files pops

module.exports = {
    description: '...', // from swagger description
    notes: ['...'], // from swagger notes
    tags: ['...'], // from swagger tags, it will add api automatically
    isRpc: false || true, // either this route is rpc or not
    auth: false || '....', // authentication type (jwt ?)
    httpMethod: '..', // (GET|POST|PUT|DELETE)
    response: '...',// response and result, bot are used for response validation, if both are omitted response will not bi validated!
    result: '...',
    route: '<route path>' // example "/a/b/c/{page}" will overwrite default defined route path
};

Return streamed file (used for large files)

if staticFileName is set file will be returned to client, but if tmpStaticFileName is set after file gets returned will be deleted. Downloaded file name could be set explicitly with downloadFileName, otherwise staticFileName or tmpStaticFileName would be used as default.

11.0.1

4 years ago

11.0.0

4 years ago

10.8.5

4 years ago

10.8.4

4 years ago

10.8.3

4 years ago

10.8.2

4 years ago

10.8.1

4 years ago

10.8.0

4 years ago

10.8.0-api.4

4 years ago

10.8.0-api.5

4 years ago

10.8.0-api.3

4 years ago

10.8.0-api.2

4 years ago

10.8.0-api.1

4 years ago

10.7.1

4 years ago

10.8.0-api.0

4 years ago

10.8.0-agency.0

4 years ago

10.7.0

5 years ago

10.6.0

5 years ago

10.5.2

5 years ago

10.3.1-amret.1

5 years ago

10.5.1

5 years ago

10.5.0

5 years ago

10.4.6

5 years ago

10.4.5

5 years ago

10.3.1-amret.0

5 years ago

10.4.4

5 years ago

10.4.3

5 years ago

10.4.2

5 years ago

10.4.1

5 years ago

10.4.0

5 years ago

9.0.1-mpay.2

5 years ago

9.0.1-mpay.1

5 years ago

9.0.1-mpay.0

5 years ago

10.3.0

6 years ago

10.2.0

6 years ago

9.1.6

6 years ago

9.1.5

6 years ago

9.1.4

6 years ago

10.1.0

6 years ago

10.0.0

6 years ago

9.1.3

6 years ago

8.13.2

6 years ago

8.13.1

6 years ago

9.1.2

6 years ago

9.1.1

6 years ago

9.1.0-rc-bahur.8

6 years ago

9.1.0-rc-bahur.7

6 years ago

9.1.0

6 years ago

9.1.0-rc-bahur.6

6 years ago

9.1.0-rc-bahur.5

6 years ago

9.1.0-rc-bahur.4

6 years ago

9.1.0-rc-bahur.3

6 years ago

9.1.0-rc-bahur.2

6 years ago

9.1.0-rc-bahur.1

6 years ago

9.1.0-rc-bahur.0

6 years ago

9.0.0

6 years ago

9.0.0-ut6.11

6 years ago

9.0.0-ut6.10

6 years ago

9.0.0-ut6.9

6 years ago

9.0.0-ut6.8

6 years ago

9.0.0-ut6.7

6 years ago

9.0.0-ut6.6

6 years ago

9.0.0-ut6.5

6 years ago

9.0.0-ut6.4

6 years ago

9.0.0-ut6.3

6 years ago

9.0.0-ut6.2

7 years ago

8.17.0

7 years ago

9.0.0-ut6.1

7 years ago

9.0.0-ut6.0

7 years ago

8.17.0-rc.1

7 years ago

8.17.0-rc.0

7 years ago

8.16.0-rc.2

7 years ago

8.16.0-rc.1

7 years ago

8.16.0-rc.0

7 years ago

8.16.1

7 years ago

8.16.0

7 years ago

8.15.0

7 years ago

8.14.0

7 years ago

8.14.0-wp3.1

7 years ago

8.14.0-wp3.0

7 years ago

8.13.0

7 years ago

8.12.5

7 years ago

8.12.4

7 years ago

8.12.3

7 years ago

8.12.2

7 years ago

8.12.1

7 years ago

8.12.1-ws.4

7 years ago

8.12.1-ws.3

7 years ago

8.12.1-ws.2

7 years ago

8.12.1-ws.1

7 years ago

8.12.1-ws.0

7 years ago

8.12.0

7 years ago

8.11.7

7 years ago

8.11.6

7 years ago

8.11.5

7 years ago

8.11.4

7 years ago

8.11.3

7 years ago

8.11.2

7 years ago

8.11.1

7 years ago

8.11.0

7 years ago

8.11.0-cors.1

7 years ago

8.11.0-cors.0

7 years ago

8.10.4

7 years ago

8.10.3

7 years ago

8.10.2

7 years ago

8.10.1

7 years ago

8.10.0

7 years ago

8.9.18

7 years ago

8.9.18-uuid.0

7 years ago

8.9.17

7 years ago

8.9.16

7 years ago

8.9.14

7 years ago

8.9.13

7 years ago

8.9.12

7 years ago

8.9.11

7 years ago

8.9.10

7 years ago

8.9.9

7 years ago

8.9.8

7 years ago

8.9.7

7 years ago

8.9.6

7 years ago

8.9.5

7 years ago

8.9.4

7 years ago

8.9.3

7 years ago

8.9.2

7 years ago

8.9.1

7 years ago

8.9.1-docs-sso.0

7 years ago

8.9.0

7 years ago

8.9.0-ws.5

7 years ago

8.9.0-ws.4

7 years ago

8.9.0-ws.3

7 years ago

8.8.2

7 years ago

8.9.0-ws.2

7 years ago

8.9.0-ws.1

7 years ago

8.9.0-ws.0

7 years ago

8.8.1

7 years ago

8.8.0

7 years ago

8.7.2

7 years ago

8.7.1

7 years ago

8.7.0

7 years ago

8.6.3

7 years ago

8.6.2

7 years ago

8.6.1

7 years ago

8.6.0

7 years ago

8.5.2

7 years ago

8.5.1

7 years ago

8.5.0

7 years ago

8.4.6

7 years ago

8.4.5

7 years ago

8.4.4

7 years ago

8.4.3

7 years ago

8.4.2

7 years ago

8.4.1

7 years ago

8.4.0

7 years ago

8.3.10

7 years ago

8.3.9

7 years ago

8.3.8

7 years ago

8.3.7

7 years ago

8.3.6

7 years ago

8.3.5

7 years ago

8.3.4

7 years ago

8.3.3

7 years ago

8.3.2

7 years ago

8.3.1

7 years ago

8.3.0

7 years ago

8.2.6

7 years ago

8.2.5

7 years ago

8.2.4

7 years ago

8.2.3

7 years ago

8.2.2

7 years ago

8.2.1

7 years ago

8.2.0

7 years ago

8.1.9

7 years ago

8.1.8

7 years ago

8.1.7

7 years ago

8.1.6

7 years ago

8.1.5

7 years ago

8.1.4

7 years ago

8.1.3

7 years ago

8.1.2

7 years ago

8.1.1

7 years ago

8.1.0

7 years ago

8.0.0

7 years ago

7.1.0

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.9.0

7 years ago

6.8.3

8 years ago

6.8.2

8 years ago

6.8.1

8 years ago

6.8.0

8 years ago

6.7.0

8 years ago

6.6.0

8 years ago

6.5.11

8 years ago

6.5.10

8 years ago

6.5.9

8 years ago

6.5.8

8 years ago

6.5.7

8 years ago

6.5.6

8 years ago

6.5.5

8 years ago

6.5.4

8 years ago

6.5.3

8 years ago

6.5.2

8 years ago

6.5.1

8 years ago

6.5.0

8 years ago

6.4.1

8 years ago

6.4.0

8 years ago

6.3.0

8 years ago

6.2.9

8 years ago

6.2.8

8 years ago

6.2.7

8 years ago

6.2.6

8 years ago

6.2.5

8 years ago

6.2.4

8 years ago

6.2.3

8 years ago