From baf6db021c56574f9dfe9a55001f2cbe2104fd76 Mon Sep 17 00:00:00 2001 From: ItsANameToo <35610748+ItsANameToo@users.noreply.github.com> Date: Wed, 18 Sep 2019 23:00:46 +0200 Subject: [PATCH] fix: re-add express server (#739) --- express-server.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 express-server.js diff --git a/express-server.js b/express-server.js new file mode 100644 index 000000000..c4c67d3e6 --- /dev/null +++ b/express-server.js @@ -0,0 +1,22 @@ +const express = require('express') +const fs = require('fs') +const path = require('path') +const history = require('connect-history-api-fallback') +const app = express() +const ip = process.env.EXPLORER_HOST || '127.0.0.1' +const port = process.env.EXPLORER_PORT || 4200 + +// Web Server +const distPath = path.join(__dirname + '/dist/') +if (fs.existsSync(distPath)) { +const staticFileMiddleware = express.static(distPath) +app.use(staticFileMiddleware) +app.use(history()) +app.use(staticFileMiddleware) +app.get('/', function (req, res) { + res.render(path.join(distPath + '/index.html')) +}) +const server = app.listen(port, ip) +} else { + throw new Error('No Dist Path - please build') +} \ No newline at end of file