fixes
This commit is contained in:
parent
9102fe41c2
commit
078ad18862
20
index.js
20
index.js
@ -15,25 +15,18 @@ const pg = require('postgresupdater')(
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(bodyParser.text({type: '*/*'}));
|
app.use(bodyParser.text({ type: '*/*' }));
|
||||||
|
|
||||||
app.post('/', (req, res, next) => {
|
app.post('/', (req, res, next) => {
|
||||||
console.log('post');
|
console.log('post');
|
||||||
if (req.query.json) {
|
if (req.query.json) {
|
||||||
// json mod requests
|
// json mod requests
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(req.body);
|
const json = JSON.parse(req.body);
|
||||||
pg.query(
|
pg.query(
|
||||||
`INSERT INTO "Log" ("App", "Type", "Client", "Message", "Misc", "Stack") Values($1, $2, $3, $4, $5, $6)`,
|
`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 {
|
} catch {
|
||||||
console.log('invalid json', req.body);
|
console.log('invalid json', req.body);
|
||||||
@ -43,7 +36,7 @@ app.post('/', (req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/*', async (req, res, next) => {
|
app.get('/', async (req, res, next) => {
|
||||||
if (typeof req.query.json != 'undefined') {
|
if (typeof req.query.json != 'undefined') {
|
||||||
const data = await pg.query(
|
const data = await pg.query(
|
||||||
`SELECT "Timestamp", "Type", "App", "Client", "Message", "Misc", "Stack" FROM "LogView"`
|
`SELECT "Timestamp", "Type", "App", "Client", "Message", "Misc", "Stack" FROM "LogView"`
|
||||||
@ -56,11 +49,12 @@ app.get('/*', async (req, res, next) => {
|
|||||||
.status(200)
|
.status(200)
|
||||||
.type('application/json')
|
.type('application/json')
|
||||||
.end(JSON.stringify(rows));
|
.end(JSON.stringify(rows));
|
||||||
next();
|
|
||||||
} else {
|
} else {
|
||||||
express.static(path.join(__dirname, 'html'))(req, res, next);
|
next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use(express.static('html'));
|
||||||
|
|
||||||
app.listen(config.port);
|
app.listen(config.port);
|
||||||
console.log('server listening on', config.port);
|
console.log('server listening on', config.port);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div>
|
<div>
|
||||||
{{json}}
|
|
||||||
<table>
|
<table>
|
||||||
<tr v-for="(row,rowKey) in json" :key="rowKey">
|
<tr v-for="(row,rowKey) in json" :key="rowKey">
|
||||||
<td v-for="(value,key) in row" :key="key">{{value}}</td>
|
<td v-for="(value,key) in row" :key="key">{{value}}</td>
|
||||||
@ -21,20 +20,34 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
data: {
|
data() {
|
||||||
json: []
|
return {
|
||||||
|
json: []
|
||||||
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
const self = this;
|
||||||
fetch("?json")
|
fetch("?json")
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => {
|
.then(json => (self.json = json));
|
||||||
this.json = json;
|
},
|
||||||
console.log(this.json);
|
watch: {
|
||||||
});
|
json() {
|
||||||
|
console.log(this.json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import url("https://cdn.scode.ovh/bootstrapLight.css");
|
@import url("https://cdn.scode.ovh/bootstrapLight.css");
|
||||||
|
|
||||||
|
td {
|
||||||
|
border: 1px solid green;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user