Skip to main content

Node / NPM / Yarn

Node.js

deepstream can also be installed as an NPM package and offers a Node.js API to interact with it programmatically.

This can be useful to build custom authentication or permissioning logic. You can view the full Node.js API here.

Install the server via npm

npm install @deepstream/server

Create a js file, e.g. start.js with the following content

const { Deepstream } = require('@deepstream/server')

/*
The server can take
1) a configuration file path
2) null to explicitly use defaults to be overriden by server.set()
3) left empty to load the base configuration from the config file located within the conf directory.
4) pass some options, missing options will be merged from the base configuration.
*/
const server = new Deepstream()

// start the server
server.start()

run the file with node

node start.js

Installing connectors​

Connectors can be installed via NPM:

  • cache redis: npm i @deepstream/cache-redis
  • cache memcached: npm i @deepstream/cache-memcached
  • clusternode redis: npm i @deepstream/clusternode-redis
  • storage rethinkdb: npm i @deepstream/storage-rethinkdb
  • storage postgres: npm i @deepstream/storage-postgres
  • storage mongodb: npm i @deepstream/storage-mongodb
  • storage elasticsearch: npm i @deepstream/storage-elasticsearch
  • logger winston: npm i @deepstream/logger-winston

Or write your own to suit your needs

Using the deepstream client in Node.js​

The deepstream javascript client can be installed via NPM and used in Node.js.

npm install @deepstream/client
const { DeepstreamClient } = require('@deepstream/client')
const client = new DeepstreamClient('localhost:6020')
client.login()