mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
docs(readme) es2015-ify
This commit is contained in:
parent
b265d1b432
commit
3a9963c81b
2 changed files with 66 additions and 38 deletions
53
HELP.md
53
HELP.md
|
|
@ -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
|
||||
|
|
|
|||
51
README.md
51
README.md
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue