From 683da55ad6f5e7d6b11d5f8ace4d3af00ed016f2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 14 Dec 2015 11:51:01 -0500 Subject: [PATCH] docs(readme) using as middleware --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 37b9dfb6..2e073e83 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,36 @@ Open url `http://localhost:8000` in browser. [![Deploy][DeployIMG]][DeployURL] +## Using as Middleware + +Cloud Commander could be used as middleware for `node.js` applications based on [socket.io](http://socket.io "Socket.IO") and [express](http://expressjs.com "Express"): + +```js +var http = require('http'), + cloudcmd = require('cloudcmd'), + express = require('express'), + io = require('socket.io'), + app = express(), + + PORT = 1337, + + server, + socket; + +server = http.createServer(app); +socket = io.listen(server); + +app.use(cloudcmd({ + socket: socket, /* used by Config, Edit (optional) and Console (required) */ + config: { /* config data (optional) */ + prefix: '/cloudcmd', /* base URL or function which returns base URL (optional) */ + } +})); + +server.listen(PORT); +``` + + ## License MIT