From b12856fe2d6bb7b04a65df42625144d8ff24c4a0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 30 Sep 2018 18:56:33 -0400 Subject: [PATCH] rebase fixes --- lib/modules/webserver/index.js | 2 +- lib/modules/webserver/server.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/modules/webserver/index.js b/lib/modules/webserver/index.js index 77b370c0f..08465853f 100644 --- a/lib/modules/webserver/index.js +++ b/lib/modules/webserver/index.js @@ -10,7 +10,7 @@ const Templates = { }; class WebServer { - constructor(embark) { + constructor(embark, options) { this.embark = embark; this.logger = embark.logger; this.events = embark.events; diff --git a/lib/modules/webserver/server.js b/lib/modules/webserver/server.js index c03caa5f6..d3a80cb55 100644 --- a/lib/modules/webserver/server.js +++ b/lib/modules/webserver/server.js @@ -5,12 +5,9 @@ const expressWebSocket = require('express-ws'); const express = require('express'); const fs = require('../../core/fs'); require('http-shutdown').extend(); -var express = require('express'); var cors = require('cors'); let path = require('path'); -var expressWebSocket = require('express-ws'); var bodyParser = require('body-parser'); -var fs = require('../../core/fs.js'); class Server { constructor(options) { @@ -18,6 +15,7 @@ class Server { this.buildDir = options.buildDir; this.events = options.events; this.port = options.port || 8000; + this.dist = options.dist || 'dist/'; this.hostname = dockerHostSwap(options.host) || defaultHost; this.isFirstStart = true; this.opened = false; @@ -75,8 +73,8 @@ class Server { this.app.use(express.static(path.join(fs.dappPath(this.dist)), {'index': ['index.html', 'index.htm']})); this.app.use('/embark', express.static(path.join(__dirname, '../../../embark-ui/build'))); - app.use(bodyParser.json()); // support json encoded bodies - app.use(bodyParser.urlencoded({extended: true})); // support encoded bodies + this.app.use(bodyParser.json()); // support json encoded bodies + this.app.use(bodyParser.urlencoded({extended: true})); // support encoded bodies expressWebSocket(this.app); @@ -128,7 +126,7 @@ class Server { this.app.get('/*', function (req, res) { self.logger.trace('webserver> GET ' + req.path); res.sendFile(path.join(fs.dappPath(self.dist, 'index.html'))); - } + }); } async.waterfall([