Додан моніторінг застосунку

Додани веб компоненти карточок територій та повідомлень
This commit is contained in:
2025-12-08 00:14:56 +02:00
parent e41590546c
commit 85483b85bb
206 changed files with 2370 additions and 595 deletions

22
api/middleware/metrics.js Normal file
View File

@@ -0,0 +1,22 @@
module.exports = (req, res, next) => {
const start = performance.now();
res.on("finish", () => {
const duration = performance.now() - start;
fetch("http://metrics:4005/push", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
type: "rest",
path: req.originalUrl,
method: req.method,
status: res.statusCode,
time: duration,
timestamp: Date.now()
})
}).catch(err => console.error(err));
});
next();
};