Support passing data sent via post request
This commit is contained in:
parent
6cc421a84e
commit
8672c8e95b
@ -1,5 +1,7 @@
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
var app = require('express')();
|
var app = require('express')();
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
var cors = require('cors');
|
||||||
|
|
||||||
module.exports.run = function(worker) {
|
module.exports.run = function(worker) {
|
||||||
var httpServer = worker.httpServer;
|
var httpServer = worker.httpServer;
|
||||||
@ -13,9 +15,12 @@ module.exports.run = function(worker) {
|
|||||||
app.get('/', function(req, res) {
|
app.get('/', function(req, res) {
|
||||||
res.render('index', { port: worker.options.port });
|
res.render('index', { port: worker.options.port });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use(cors({ methods: 'POST' }));
|
||||||
|
app.use(bodyParser.json());
|
||||||
app.post('/', function(req, res) {
|
app.post('/', function(req, res) {
|
||||||
if (!req.body.data) return res.status(404).end();
|
if (!req.body) return res.status(404).end();
|
||||||
scServer.exchange.publish('log', req.body.data);
|
scServer.exchange.publish('log', req.body);
|
||||||
res.send('OK');
|
res.send('OK');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/zalmoxisus/remotedev-server",
|
"homepage": "https://github.com/zalmoxisus/remotedev-server",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.15.0",
|
||||||
|
"cors": "^2.7.1",
|
||||||
"ejs": "^2.4.1",
|
"ejs": "^2.4.1",
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user