Create trendings.js
Browse files- plugins/trendings.js +59 -0
plugins/trendings.js
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import axios from 'axios';
|
3 |
+
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
4 |
+
const TrendingNewRoutes = express.Router();
|
5 |
+
|
6 |
+
const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
|
7 |
+
|
8 |
+
const ComboTrending = async (limit) => {
|
9 |
+
const options = {
|
10 |
+
method: 'GET',
|
11 |
+
url: 'https://randydev-meta-ai.hf.space/combo-trending',
|
12 |
+
params: {
|
13 |
+
limit: limit
|
14 |
+
}
|
15 |
+
};
|
16 |
+
try {
|
17 |
+
const response = await axios.request(options);
|
18 |
+
return response.data;
|
19 |
+
} catch (error) {
|
20 |
+
console.error(error);
|
21 |
+
return null;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @swagger
|
27 |
+
* /api/v1/trending/combo:
|
28 |
+
* get:
|
29 |
+
* summary: Combo Trending
|
30 |
+
* tags: [Trending]
|
31 |
+
* parameters:
|
32 |
+
* - in: query
|
33 |
+
* name: limit
|
34 |
+
* required: true
|
35 |
+
* description: null
|
36 |
+
* schema:
|
37 |
+
* type: number
|
38 |
+
* - in: header
|
39 |
+
* name: x-api-key
|
40 |
+
* required: true
|
41 |
+
* description: API key for authentication
|
42 |
+
* schema:
|
43 |
+
* type: string
|
44 |
+
* responses:
|
45 |
+
* 200:
|
46 |
+
* description: Success
|
47 |
+
*/
|
48 |
+
TrendingNewRoutes.get("/api/v1/trending/combo", authenticateApiKey, apiLimiter, async (req, res) => {
|
49 |
+
const limit = req.query.limit;
|
50 |
+
if (!limit) {
|
51 |
+
return res.status(400).json({ error: "Invalid or missing username" });
|
52 |
+
}
|
53 |
+
try {
|
54 |
+
const result = await ComboTrending(limit);
|
55 |
+
res.json(result);
|
56 |
+
} catch (error) {
|
57 |
+
res.status(500).json({ error: "Failed to fetch user info" });
|
58 |
+
}
|
59 |
+
});
|