Initial commit

This commit is contained in:
2021-08-01 17:19:21 -04:00
commit 48bdeeba33
36 changed files with 23143 additions and 0 deletions

1
blog/moderation/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

32
blog/moderation/index.js Normal file
View 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

File diff suppressed because it is too large Load Diff

View 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"
}
}