fixes
This commit is contained in:
parent
9102fe41c2
commit
078ad18862
18
index.js
18
index.js
@ -15,7 +15,7 @@ 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');
|
||||
@ -26,14 +26,7 @@ app.post('/', (req, res, next) => {
|
||||
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);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div>
|
||||
{{json}}
|
||||
<table>
|
||||
<tr v-for="(row,rowKey) in json" :key="rowKey">
|
||||
<td v-for="(value,key) in row" :key="key">{{value}}</td>
|
||||
@ -21,20 +20,34 @@
|
||||
<script>
|
||||
export default {
|
||||
name: "App",
|
||||
data: {
|
||||
data() {
|
||||
return {
|
||||
json: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
const self = this;
|
||||
fetch("?json")
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
this.json = json;
|
||||
.then(json => (self.json = json));
|
||||
},
|
||||
watch: {
|
||||
json() {
|
||||
console.log(this.json);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import url("https://cdn.scode.ovh/bootstrapLight.css");
|
||||
|
||||
td {
|
||||
border: 1px solid green;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user