From 00ecc2b9996b34a48806b8aa3023147cefe37702 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Jan 2022 20:20:49 +0100 Subject: [PATCH] cleanup run script (frontend) include new run script(admin) --- admin/run/server.js | 22 ++++++++++++++-------- frontend/run/server.js | 26 +++++--------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/admin/run/server.js b/admin/run/server.js index 97a525427..7d75acba8 100644 --- a/admin/run/server.js +++ b/admin/run/server.js @@ -1,15 +1,21 @@ // Imports const express = require('express') -const serveStatic = require('serve-static') +const path = require('path') -// Port -const port = process.env.PORT || 8080 +// Host & Port +const hostname = '127.0.0.1' +const port = process.env.PORT || 3000 // Express Server const app = express() -// eslint-disable-next-line node/no-path-concat -app.use(serveStatic(__dirname + '/../dist')) -app.listen(port) +// Serve files +app.use(express.static(path.join(__dirname, '../dist'))) +// Default to index.html +app.get('*', (req, res) => { + res.sendFile(path.join(__dirname, '../dist/index.html')) +}) -// eslint-disable-next-line no-console -console.log(`http://admin:${port} server started.`) +app.listen(port, hostname, () => { + // eslint-disable-next-line no-console + console.log('Listening at http://%s:%s/', hostname, port) +}) diff --git a/frontend/run/server.js b/frontend/run/server.js index 12a9cbd79..7d75acba8 100644 --- a/frontend/run/server.js +++ b/frontend/run/server.js @@ -1,33 +1,17 @@ -/* // Imports const express = require('express') -const serveStatic = require('serve-static') +const path = require('path') -// Port +// Host & Port +const hostname = '127.0.0.1' const port = process.env.PORT || 3000 // Express Server const app = express() -// eslint-disable-next-line node/no-path-concat -app.use(serveStatic(__dirname + '/../dist')) -app.listen(port) - -// eslint-disable-next-line no-console -console.log(`http://frontend:${port} server started.`) -*/ - -const express = require('express') -const path = require('path') - -const hostname = '127.0.0.1' -const port = process.env.PORT || 3000 - -const app = express() +// Serve files app.use(express.static(path.join(__dirname, '../dist'))) - +// Default to index.html app.get('*', (req, res) => { - // eslint-disable-next-line no-console - console.log('Request', req) res.sendFile(path.join(__dirname, '../dist/index.html')) })