add webhook
This commit is contained in:
parent
6f68b5890b
commit
ca58802df7
|
|
@ -15,6 +15,7 @@
|
|||
"@adonisjs/session": "^6.4.0",
|
||||
"@adonisjs/view": "^6.2.0",
|
||||
"axios": "^1.4.0",
|
||||
"child_process": "^1.0.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"fs": "^0.0.1-security",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
|
|
@ -2184,6 +2185,11 @@
|
|||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/child_process": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz",
|
||||
"integrity": "sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g=="
|
||||
},
|
||||
"node_modules/chokidar": {
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||
|
|
@ -9854,6 +9860,11 @@
|
|||
"integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==",
|
||||
"dev": true
|
||||
},
|
||||
"child_process": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz",
|
||||
"integrity": "sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g=="
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
"@adonisjs/session": "^6.4.0",
|
||||
"@adonisjs/view": "^6.2.0",
|
||||
"axios": "^1.4.0",
|
||||
"child_process": "^1.0.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"fs": "^0.0.1-security",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import KeyValue from "App/Models/KeyValue";
|
|||
import ErpsController from "App/Controllers/Http/ErpsController";
|
||||
import LogReport from "App/Models/LogReport";
|
||||
import Database from "@ioc:Adonis/Lucid/Database";
|
||||
import { exec } from "child_process";
|
||||
|
||||
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
||||
|
||||
|
|
@ -56,14 +57,16 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
|
|||
request.params().name
|
||||
);
|
||||
let logsDetect = await Database.rawQuery(
|
||||
"select * from log_reports where id_file = " +
|
||||
fileDetect?.id_ldf
|
||||
"select * from log_reports where id_file = " + fileDetect?.id_ldf
|
||||
);
|
||||
|
||||
let detectedLines = []
|
||||
let listLine = logsDetect[0].map(obj=>obj.line).filter((value, index, self) => {
|
||||
return self.indexOf(value) === index;
|
||||
}).sort((a, b) => a - b)
|
||||
let detectedLines = [];
|
||||
let listLine = logsDetect[0]
|
||||
.map((obj) => obj.line)
|
||||
.filter((value, index, self) => {
|
||||
return self.indexOf(value) === index;
|
||||
})
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
const content = await axios.get(
|
||||
"http://192.168.5.7:8080/" + request.params().name
|
||||
|
|
@ -95,9 +98,9 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
|
|||
}
|
||||
});
|
||||
});
|
||||
listLine.map((u)=>{
|
||||
detectedLines.push(data[u-1])
|
||||
})
|
||||
listLine.map((u) => {
|
||||
detectedLines.push(data[u - 1]);
|
||||
});
|
||||
// console.log(data)
|
||||
response.send(
|
||||
"<html>\
|
||||
|
|
@ -126,7 +129,10 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
|
|||
border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));\
|
||||
border-image: initial;\
|
||||
padding: 2px;'>" +
|
||||
"<b>Detected lines in file:</b>\n"+detectedLines.join("\n")+"\n\n"+data.join("\n") +
|
||||
"<b>Detected lines in file:</b>\n" +
|
||||
detectedLines.join("\n") +
|
||||
"\n\n" +
|
||||
data.join("\n") +
|
||||
"</div>\
|
||||
</body>\
|
||||
</html>"
|
||||
|
|
@ -166,6 +172,28 @@ Route.post("/api/addValue", async ({ request, response }) => {
|
|||
}
|
||||
});
|
||||
|
||||
Route.post("/api/test", async ({ request, response }) => {
|
||||
|
||||
Route.post("/gitlab-webhook", ({ request, response }) => {
|
||||
// Kiểm tra xem đó có phải sự kiện bạn muốn xử lý không
|
||||
// if (request.headers['x-gitlab-event'] === 'push') {
|
||||
// // Lấy dữ liệu sự kiện từ req.body
|
||||
// const eventData = req.body;
|
||||
|
||||
// // Xử lý dữ liệu sự kiện ở đây
|
||||
// console.log('Received push event from GitLab:');
|
||||
// console.log(JSON.stringify(eventData, null, 2));
|
||||
// }
|
||||
console.log(request.headers());
|
||||
console.log(request.all());
|
||||
console.log("New event ---> ", request.all().object_kind);
|
||||
// exec(
|
||||
// "/home/joseph/adonis-gitlab-webhook/gitea.sh",
|
||||
// (error, stdout, stderr) => {
|
||||
// if (error) {
|
||||
// console.error(`Error executing command: ${error}`);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// console.log(`Command output:\n${stdout}`);
|
||||
// }
|
||||
// );
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue