Create copilot.js
Browse files- plugins/copilot.js +31 -0
plugins/copilot.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import { Copilot2Trip } from '../lib/scrapper.js';
|
3 |
+
const CopilotRoutes = express.Router();
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @swagger
|
7 |
+
* /api/v1/ai/copilot2-trip:
|
8 |
+
* get:
|
9 |
+
* summary: copilot2 Trip
|
10 |
+
* parameters:
|
11 |
+
* - in: query
|
12 |
+
* name: query
|
13 |
+
* required: true
|
14 |
+
* description: The query to be processed.
|
15 |
+
* schema:
|
16 |
+
* type: string
|
17 |
+
* responses:
|
18 |
+
* 200:
|
19 |
+
* description: Success
|
20 |
+
*/
|
21 |
+
GptRoutes.get("/api/v1/ai/copilot2-trip", async (req, res) => {
|
22 |
+
try {
|
23 |
+
const query = req.query.query;
|
24 |
+
const results = await Copilot2Trip(query);
|
25 |
+
res.json({ results });
|
26 |
+
} catch (error) {
|
27 |
+
res.status(401).json({ error: error.message });
|
28 |
+
}
|
29 |
+
});
|
30 |
+
|
31 |
+
export { CopilotRoutes };
|