import { Router } from "express";
import { Role } from "@prisma/client";
import { requireAuth, requireRole } from "../../middleware/auth";
import { searchController } from "./search.controller";

const router = Router();

// All search endpoints require authentication
router.use(requireAuth);

// GET /api/search/quick?q=...&limit=8
router.get(
  "/quick",
  requireRole([Role.ADMIN, Role.MANAGER]),
  (req, res) => searchController.quick(req, res)
);

// GET /api/search?q=...&page=1&limit=25
router.get(
  "/",
  requireRole([Role.ADMIN, Role.MANAGER]),
  (req, res) => searchController.full(req, res)
);

export default router;
