Refactor discordWebhookSuspisiousAlertMiddleware.js to use setupData variable within the sendDiscordWebhook function
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
18
.drone.yml
18
.drone.yml
@@ -13,13 +13,27 @@ steps:
|
||||
- npm install
|
||||
- node -v
|
||||
|
||||
- name: extract-version
|
||||
image: node:alpine
|
||||
commands:
|
||||
- npm install -g json
|
||||
- echo $(json -f package.json version) > .version
|
||||
volumes:
|
||||
- name: shared
|
||||
path: /drone/src
|
||||
|
||||
- name: build-docker-image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: swiftlogiclabs/cdn-app-insider
|
||||
tags: latest
|
||||
tags:
|
||||
- latest
|
||||
- $(cat .version)
|
||||
dockerfile: Dockerfile
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
from_secret: docker_password
|
||||
volumes:
|
||||
- name: shared
|
||||
path: /drone/src
|
||||
@@ -2,7 +2,6 @@ const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const setupFilePath = path.join(__dirname, '../data', 'setup.json');
|
||||
const setupData = JSON.parse(fs.readFileSync(setupFilePath, 'utf-8'));
|
||||
|
||||
function sendDiscordWebhook(url, req, statusCode) {
|
||||
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`;
|
||||
@@ -37,14 +36,11 @@ function sendDiscordWebhook(url, req, statusCode) {
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
axios.post(url, data)
|
||||
.catch((error) => {
|
||||
console.error(`Erreur lors de l'envoi du webhook à Discord: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
function discordWebhookSuspisiousAlertMiddleware(req, res, next) {
|
||||
const setupData = JSON.parse(fs.readFileSync(setupFilePath, 'utf-8'));
|
||||
|
||||
res.on('finish', () => {
|
||||
const discordWebhookUrl = setupData[0].webhooks_discord;
|
||||
sendDiscordWebhook(discordWebhookUrl, req, res.statusCode);
|
||||
|
||||
Reference in New Issue
Block a user