move console api call into console

This commit is contained in:
Iuri Matias 2018-03-13 06:46:58 -04:00
parent 8e9a357448
commit 3d5ceb74be
3 changed files with 15 additions and 4 deletions

View File

@ -2,10 +2,20 @@ let utils = require('../utils/utils.js');
class Console {
constructor(options) {
const self = this;
this.events = options.events;
this.plugins = options.plugins;
this.version = options.version;
this.contractsConfig = options.contractsConfig;
let plugin = this.plugins.createPlugin('dashboard', {});
plugin.registerAPICall(
'post',
'/embark/console',
(req, res) => {
self.events.request('console:command', req.body.cmd, res.send.bind(res));
}
);
}
runCode(code) {

View File

@ -5,6 +5,7 @@ require('http-shutdown').extend();
var express = require('express');
let path = require('path');
var expressWebSocket = require('express-ws');
var bodyParser = require('body-parser');
class Server {
constructor(options) {
@ -32,6 +33,9 @@ class Server {
app.use(serve);
app.use('/embark', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
expressWebSocket(app);
app.ws('/embark/logs', function(ws, req) {
@ -49,10 +53,6 @@ class Server {
res.send('Welcome to Embark')
});
app.get('/embark/console', function (req, res) {
self.events.request('console:command', req.query.cmd, res.send.bind(res));
});
app.listen(this.port);
this.logger.info(__("webserver available at") + " " + ("http://" + this.hostname + ":" + this.port).bold.underline.green);

View File

@ -34,6 +34,7 @@
"bip39": "^2.5.0",
"chokidar": "^2.0.3",
"clone-deep": "^4.0.0",
"body-parser": "^1.18.2",
"colors": "^1.1.2",
"commander": "^2.15.1",
"css-loader": "^0.28.11",