mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
docs(readme) using as middleware
This commit is contained in:
parent
51685d413d
commit
683da55ad6
1 changed files with 30 additions and 0 deletions
30
README.md
30
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue