// apps/api/src/routes/health.routes.js

const express = require('express');
const router = express.Router();
const { DatabaseClient } = require('../../../../packages/db/client');

router.get('/', async (req, res) => {
    res.json({
        status: 'ok',
        timestamp: new Date().toISOString(),
        uptime: process.uptime()
    });
});

router.get('/db', async (req, res) => {
    try {
        const db = new DatabaseClient();
        await db.connect();
        await db.query('SELECT 1');
        res.json({ status: 'ok', database: 'connected' });
    } catch (error) {
        res.status(500).json({ status: 'error', database: 'disconnected', error: error.message });
    }
});

module.exports = router;