aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNick Coutsos <[email protected]>2022-05-06 21:10:30 -0400
committerNick Coutsos <[email protected]>2022-05-06 21:10:30 -0400
commit0590fdcc4c1db67e8dda7fbdd781176b63163933 (patch)
tree29afd33bd942b6f6216fb85b297846f3e265fd09
parent42f2c56b12f783bd5e69337805c52817f810060a (diff)
downloadkeymap-editor-0590fdcc4c1db67e8dda7fbdd781176b63163933.tar.gz
keymap-editor-0590fdcc4c1db67e8dda7fbdd781176b63163933.zip
Replace vue app with react
-rw-r--r--.env.template2
-rw-r--r--api/routes/application.js37
2 files changed, 9 insertions, 30 deletions
diff --git a/.env.template b/.env.template
index b6fe7dc..c1a5efd 100644
--- a/.env.template
+++ b/.env.template
@@ -3,4 +3,4 @@ GITHUB_APP_NAME=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_OAUTH_CALLBACK_URL=
-APP_BASE_URL= \ No newline at end of file
+APP_BASE_URL=http://localhost:3000 \ No newline at end of file
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