docs(readme) es2015-ify

This commit is contained in:
coderaiser 2016-10-28 12:22:33 +03:00
parent b265d1b432
commit 3a9963c81b
2 changed files with 66 additions and 38 deletions

53
HELP.md
View file

@ -282,33 +282,48 @@ 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"):
Init `package.json`:
```
npm init -y
```
Install dependencies:
```
npm i cloudcmd express socket.io -S
```
And create `index.js`:
```js
var http = require('http'),
cloudcmd = require('cloudcmd'),
express = require('express'),
io = require('socket.io'),
app = express(),
PORT = 1337,
PREFIX = '/cloudcmd',
server,
socket;
server = http.createServer(app);
socket = io.listen(server, {
path: PREFIX + '/socket.io'
const http = require('http');
const cloudcmd = require('cloudcmd');
const io = require('socket.io');
const app = require('express')();
const port = 1337;
const prefix = '/cloudcmd';
const server = http.createServer(app);
const socket = io.listen(server, {
path: `${prefix}/socket.io`
});
const config = {
prefix /* base URL or function which returns base URL (optional) */
};
app.use(cloudcmd({
socket: socket, /* used by Config, Edit (optional) and Console (required) */
config: { /* config data (optional) */
prefix: PREFIX, /* base URL or function which returns base URL (optional) */
}
socket, /* used by Config, Edit (optional) and Console (required) */
config, /* config data (optional) */
}));
server.listen(PORT);
server.listen(port);
```
And you are ready to go.
Server
---------------
Standard practices say no non-root process gets to talk to

View file

@ -57,31 +57,44 @@ Open url `http://localhost:8000` in browser.
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"):
Init `package.json`:
```
npm init -y
```
Install dependencies:
```
npm i cloudcmd express socket.io -S
```
And create `index.js`:
```js
var http = require('http'),
cloudcmd = require('cloudcmd'),
express = require('express'),
io = require('socket.io'),
app = express(),
PORT = 1337,
PREFIX = '/cloudcmd',
server,
socket;
server = http.createServer(app);
socket = io.listen(server, {
path: PREFIX + '/socket.io'
const http = require('http');
const cloudcmd = require('cloudcmd');
const io = require('socket.io');
const app = require('express')();
const port = 1337;
const prefix = '/cloudcmd';
const server = http.createServer(app);
const socket = io.listen(server, {
path: `${prefix}/socket.io'
});
const config = {
prefix /* base URL or function which returns base URL (optional) */
}
app.use(cloudcmd({
socket: socket, /* used by Config, Edit (optional) and Console (required) */
config: { /* config data (optional) */
prefix: PREFIX, /* base URL or function which returns base URL (optional) */
}
socket, /* used by Config, Edit (optional) and Console (required) */
config, /* config data (optional) */
}));
server.listen(PORT);
server.listen(port);
```
Docker