the-tip-top-backend/backend/server.js
soufiane 5e75ea8bb5
All checks were successful
the-tip-top-backend/pipeline/head This commit looks good
push
2025-10-24 14:15:41 +02:00

27 lines
685 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const express = require('express');
const client = require('prom-client');
const app = express();
const port = process.env.PORT || 4000;
// Créer un registre de métriques
const register = new client.Registry();
// Collecte des métriques système par défaut (CPU, mémoire, etc.)
client.collectDefaultMetrics({ register });
// Route /metrics pour Prometheus
app.get('/metrics', async (req, res) => {
res.set('Content-Type', register.contentType);
res.end(await register.metrics());
});
// Exemple de route dapplication
app.get('/', (req, res) => {
res.send('Hello from backend');
});
app.listen(port, () => {
console.log(`✅ Backend running on port ${port}`);
});