import { Router } from 'express';
import { query } from '../db/client.js';

const router = Router();

router.get('/', (_req, res) => res.json({ ok: true }));

router.get('/ready', async (_req, res) => {
  try {
    await query('SELECT 1');
    res.json({ ok: true, db: 'up' });
  } catch {
    res.status(503).json({ ok: false, db: 'down' });
  }
});

export default router;
