import express from 'express';
import { Copilot2Trip } from '../lib/scrapper.js';
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
const CopilotRoutes = express.Router();


/**
 * @swagger
 * /api/v1/ai/copilot2-trip:
 *   get:
 *     summary: copilot2 Trip
 *     tags: [AI]
 *     parameters:
 *       - in: query
 *         name: q
 *         required: true
 *         description: The query to be processed.
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
CopilotRoutes.get("/api/v1/ai/copilot2-trip", authenticateApiKey, apiLimiter, async (req, res) => {
    try {
        const q = req.query.q;
        const results = await Copilot2Trip(q);
        res.json({ results });
    } catch (error) {
        res.status(401).json({ error: error.message });
    }
});

export { CopilotRoutes };