-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (20 loc) · 715 Bytes
/
server.js
File metadata and controls
24 lines (20 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const app = express();
const port = 3000;
const writeStory = require('./writeStory.js');
app.use(express.json());
app.use(express.static('public'));
app.post('/', async (req, res) => {
const {token, region, story} = req.body;
try {
let logger = require('logzio-nodejs').createLogger({token, host: `listener${region ? '-' + region : ''}.logz.io`});
let logs = await writeStory(story);
logs.forEach(line => {
logger.log(line)
});
res.status(200).send('Succesfully shipped story');
} catch (e) {
res.status(500).send(e.message);
}
})
app.listen(port, () => console.log(`app listening on port ${port}`))