add 2nd endpoint to webserver; use express

This commit is contained in:
Iuri Matias 2018-02-25 19:01:50 -05:00
parent bcffa62294
commit d03139b93d
3 changed files with 21 additions and 3 deletions

View File

@ -0,0 +1 @@
Welcome to Embark!

View File

@ -3,6 +3,8 @@ let http = require('http');
let serveStatic = require('serve-static');
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
require('http-shutdown').extend();
var express = require('express');
let path = require('path');
class Server {
constructor(options) {
@ -25,15 +27,29 @@ class Server {
}
let serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']});
this.server = http.createServer(function onRequest(req, res) {
serve(req, res, finalhandler(req, res));
}).withShutdown();
var app = express();
app.use(serve);
app.use('/backend', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
//app.get('/embark', function (req, res) {
// res.send('Welcome to Embark')
//});
app.listen(this.port);
this.logger.info(__("webserver available at") +
" " +
("http://" + canonicalHost(this.hostname) +
":" + this.port).bold.underline.green);
this.server.listen(this.port, this.hostname);
//this.server = http.createServer(function onRequest(req, res) {
// serve(req, res, finalhandler(req, res));
//}).withShutdown();
//this.logger.info("webserver available at " + ("http://" + this.hostname + ":" + this.port).bold.underline.green);
//this.server.listen(this.port, this.hostname);
if (callback) {
callback();
}

View File

@ -43,6 +43,7 @@
"eth-ens-namehash": "^2.0.8",
"eth-lib": "^0.2.8",
"ethereumjs-wallet": "0.6.0",
"express": "^4.16.2",
"file-loader": "^1.1.5",
"finalhandler": "^1.1.1",
"follow-redirects": "^1.2.4",