From 078ad18862086f66a4bb2ba65616b5332ab7a749 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Thu, 26 Sep 2019 15:07:56 +0200 Subject: [PATCH] fixes --- index.js | 20 +++++++------------- web/src/App.vue | 27 ++++++++++++++++++++------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index 31d1236..99263e4 100644 --- a/index.js +++ b/index.js @@ -15,25 +15,18 @@ const pg = require('postgresupdater')( const app = express(); -app.use(bodyParser.text({type: '*/*'})); +app.use(bodyParser.text({ type: '*/*' })); app.post('/', (req, res, next) => { console.log('post'); if (req.query.json) { // json mod requests - } else { + } else { try { const json = JSON.parse(req.body); pg.query( `INSERT INTO "Log" ("App", "Type", "Client", "Message", "Misc", "Stack") Values($1, $2, $3, $4, $5, $6)`, - [ - json.app, - json.type, - json.client, - json.message, - json.misc, - json.stack - ] + [json.app, json.type, json.client, json.message, json.misc, json.stack] ); } catch { console.log('invalid json', req.body); @@ -43,7 +36,7 @@ app.post('/', (req, res, next) => { next(); }); -app.get('/*', async (req, res, next) => { +app.get('/', async (req, res, next) => { if (typeof req.query.json != 'undefined') { const data = await pg.query( `SELECT "Timestamp", "Type", "App", "Client", "Message", "Misc", "Stack" FROM "LogView"` @@ -56,11 +49,12 @@ app.get('/*', async (req, res, next) => { .status(200) .type('application/json') .end(JSON.stringify(rows)); - next(); } else { - express.static(path.join(__dirname, 'html'))(req, res, next); + next(); } }); +app.use(express.static('html')); + app.listen(config.port); console.log('server listening on', config.port); diff --git a/web/src/App.vue b/web/src/App.vue index 538e842..cf7531e 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,7 +1,6 @@