mongodb
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -18,7 +18,7 @@ COPY middlewares/ ./middlewares/
|
||||
COPY routes/ ./routes/
|
||||
COPY services/ ./services/
|
||||
COPY utils/ ./utils/
|
||||
COPY workers.json ./workers.json
|
||||
COPY ../workers.json ./workers.json
|
||||
|
||||
# Exponer puerto
|
||||
EXPOSE 3001
|
||||
|
||||
@@ -6,6 +6,31 @@ import { broadcast } from '../services/websocket.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Health check (no requiere autenticación)
|
||||
router.get('/health', async (req, res) => {
|
||||
try {
|
||||
// Verificar que MongoDB está disponible (opcional, no falla si no está)
|
||||
const db = getDB();
|
||||
const mongodbStatus = db ? 'connected' : 'unavailable';
|
||||
|
||||
res.json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
mongodb: mongodbStatus,
|
||||
service: 'wallamonitor-backend'
|
||||
});
|
||||
} catch (error) {
|
||||
// Incluso si hay un error, el servidor está funcionando, así que retornamos ok
|
||||
res.json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
mongodb: 'error',
|
||||
service: 'wallamonitor-backend',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Obtener estadísticas (requiere autenticación obligatoria)
|
||||
router.get('/stats', basicAuthMiddleware, async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user