aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/routes/application.js
diff options
context:
space:
mode:
Diffstat (limited to 'api/routes/application.js')
-rw-r--r--api/routes/application.js37
1 files changed, 8 insertions, 29 deletions
diff --git a/api/routes/application.js b/api/routes/application.js
index add60be..7a786a8 100644
--- a/api/routes/application.js
+++ b/api/routes/application.js
@@ -1,52 +1,31 @@
const childProcess = require('child_process')
const path = require('path')
-const express = require('express')
-const expressWs = require('express-ws')
const config = require('../config')
-const appDir = path.join(__dirname, '..', '..', 'application')
+const appDir = path.join(__dirname, '..', '..', 'app')
+const API_BASE_URL = 'http://localhost:8080'
+const APP_BASE_URL = 'http://localhost:3000'
function init (app) {
- expressWs(app)
-
const opts = {
cwd: appDir,
env: Object.assign({}, process.env, {
ENABLE_LOCAL: true,
ENABLE_GITHUB: config.ENABLE_GITHUB,
GITHUB_APP_NAME: config.GITHUB_APP_NAME,
- API_BASE_URL: 'http://localhost:8080',
- APP_BASE_URL: 'http://localhost:8080/application'
+ API_BASE_URL,
+ APP_BASE_URL
})
}
- childProcess.execFile('npm', ['run', 'build-watch'], opts, err => {
+ childProcess.execFile('npm', ['start'], opts, err => {
console.error(err)
console.error('Application serving failed')
process.exit(1)
})
-
- app.get('/', (req, res) => res.redirect('/application'))
- app.use('/application', express.static(path.join(appDir, 'dist')))
-
- const subscribers = []
- app.ws('/console', (ws, req) => {
- const { remoteAddress } = req.connection
- subscribers.push(ws)
-
- console.info(`[${new Date()}] [${remoteAddress}] connected`)
-
- ws.onerror = err => {
- console.error(`[${new Date()}] [${remoteAddress}]`, err)
- }
-
- ws.onclose = () => {
- console.info(`[${new Date()}] [${remoteAddress}] disconnected`)
- const index = subscribers.indexOf(ws)
- subscribers.splice(index, 1)
- }
- })
+
+ app.get('/', (req, res) => res.redirect(APP_BASE_URL))
}
module.exports = init