fixes
This commit is contained in:
parent
0405443391
commit
4960433c0a
21
index.js
21
index.js
@ -1,6 +1,7 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
||||
|
||||
@ -14,25 +15,29 @@ const pg = require('postgresupdater')(
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(express.json());
|
||||
app.use(bodyParser.text({type: '*/*'}));
|
||||
|
||||
app.post('/', (req, res, next) => {
|
||||
console.log('post');
|
||||
if (req.query.json) {
|
||||
// json mod requests
|
||||
} else {
|
||||
console.log(req.body);
|
||||
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)`,
|
||||
[
|
||||
req.body.app,
|
||||
req.body.type,
|
||||
req.body.client,
|
||||
req.body.message,
|
||||
req.body.misc,
|
||||
req.body.stack
|
||||
json.app,
|
||||
json.type,
|
||||
json.client,
|
||||
json.message,
|
||||
json.misc,
|
||||
json.stack
|
||||
]
|
||||
);
|
||||
} catch {
|
||||
console.log('invalid json', req.body);
|
||||
}
|
||||
}
|
||||
res.status(201).end();
|
||||
next();
|
||||
|
@ -13,6 +13,7 @@
|
||||
"author": "Timo Hocker",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"postgresupdater": "^1.0.0"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user