deepstreamio-server-client-plugin

1.2.0 • Public • Published

deepstreamio-server-client-plugin

NPM version Build Status Coveralls Status Dependency Status Downloads

A plugin to expose a deepstream client on the server

Install

npm i -D deepstreamio-server-client-plugin

Usage

const server = /* create deepstream server */;
import clientPlugin, { extendPermissionHandler } from "deepstreamio-server-client-plugin"
 
// Attach to server
const port = 6021; // Your server's TCP port
const bytes = 64; // More bytes = more secure but slower
clientPlugin(server, port, bytes);
 
// extendPermissionHandler handles authenticating the server for you, and then
// defers to your permissionHandler
server.set('permissionHandler', extendPermissionHandler({
    isValidUser: function(conn, auth, cb) {
        // Handle client auth
    },
    canPerformAction: function(username, message, cb) {
        // Handle client permissions
    }
}));
 
// Wait for "clientReady" before you try to use the client
// "clientReady" won't fire until the server starts
server.once('clientReady', () => {
    // Use client
});

Developing

This project uses the RISE yeoman generator. For development workflow, see the workflow guide. Cheatsheet:

  • Add code to src/index.js and tests to test/index.js.
  • Lint, build and test a project with npm run build.
  • Build and watch changes in src/ with npm run watch
  • Run only tests with npm run test.
  • Check coverage with npm run coverage.
  • Generate a TOC for the CHANGELOG with npm run toc
  • Deploy to a remote origin with npm run deploy.
  • Bump version and publish a package with npm run major or minor/patch

License

MIT © Chris Morrell

Readme

Keywords

Package Sidebar

Install

npm i deepstreamio-server-client-plugin

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • inxilpro