1.2.0 • Published 10 years ago
deepstreamio-server-client-plugin v1.2.0
deepstreamio-server-client-plugin
A plugin to expose a deepstream client on the server
Install
npm i -D deepstreamio-server-client-pluginUsage
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.jsand tests totest/index.js. - Lint, build and test a project with
npm run build. - Build and watch changes in
src/withnpm run watch - Run only tests with
npm run test. - Check coverage with
npm run coverage. - Generate a TOC for the
CHANGELOGwithnpm run toc - Deploy to a remote origin with
npm run deploy. - Bump version and publish a package with
npm run majororminor/patch
License
MIT © Chris Morrell