Initial commit
This commit is contained in:
1
blog/moderation/.gitignore
vendored
Normal file
1
blog/moderation/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
32
blog/moderation/index.js
Normal file
32
blog/moderation/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const expres = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const axios = require('axios');
|
||||
|
||||
|
||||
const app = expres();
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.post('/events', async (req, res) => {
|
||||
const { type, data } = req.body;
|
||||
|
||||
if(type === 'CommentCreated') {
|
||||
const status = data.content.includes('orange') ? 'rejected' : 'approved';
|
||||
await axios.post('http://localhost:4005/events', {
|
||||
type: 'CommentModerated',
|
||||
data: {
|
||||
id: data.id,
|
||||
postId: data.postId,
|
||||
status,
|
||||
content: data.content
|
||||
}
|
||||
}).catch(error => console.log(error));
|
||||
}
|
||||
|
||||
res.send({});
|
||||
});
|
||||
|
||||
|
||||
app.listen(4003, () => {
|
||||
console.log('Listening on 4003');
|
||||
});
|
||||
|
||||
1242
blog/moderation/package-lock.json
generated
Normal file
1242
blog/moderation/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
blog/moderation/package.json
Normal file
17
blog/moderation/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "blog",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "nodemon index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"express": "^4.17.1",
|
||||
"nodemon": "^2.0.9"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user