// src/routes/adminMetrics.routes.js
const express = require('express');
const router = express.Router();
const pool = require('../config/db');
const { requireAuth } = require('../utils/jwt');
const requireAdmin = require('../middleware/requireAdmin');

// GET /api/admin/metrics/users/total  (solo admin)
router.get('/users/total', requireAuth, requireAdmin(), async (req, res, next) => {
  try {
    const [[{ total }]] = await pool.query(`SELECT COUNT(*) AS total FROM usuarios`);
    res.json({ total });
  } catch (err) { next(err); }
});

module.exports = router;
