@hume/app-ws

Websockets service application abstraction to decrease the load in the HTTP APIs for common read only requests.

Stats

StarsIssuesVersionUpdatedCreatedSize
@hume/app-ws
0.7.23 years ago3 years agoMinified + gzip package size for @hume/app-ws in KB

Readme

hume WS app

Websockets service application abstraction to decrease the load in the HTTP APIs for common read only requests.

For now it keeps an updated cache in memory of the needed data. All the connected clients will receive an update of the requested one in an interval.

Install

:coffee: Install Node.js v8 and then:

npm i @hume/app-ws

Dependencies

  • Install the dependencies for the websockets library from your OS package manager.

Use

:pencil: Please visit the the example.

Client side

Two query parameters are supported:

  • token (string) - Mandatory, see the last point of this document.
  • filter (string) - To serve only the the contend under one key of the cache. (default: null)

Please visit the example.

API

:eyes: Full specification.

app.start(cache, token, apm) -> null

Start the LoopBack app.

  • cache (async function) - Method to get the data to serve.
  • token (string) - For now we only need basic auth to avoid automated scrappers. If not passed auth is disabled. (default: null)
  • apm (object) - Elastic APM express.js agent instance (already started).

async app.stop() -> null

Stop the websocket service, useful in tests.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.