randydev commited on
Commit
d03f93a
·
verified ·
1 Parent(s): 8ad6d02

Update plugins/trendings.js

Browse files
Files changed (1) hide show
  1. plugins/trendings.js +114 -0
plugins/trendings.js CHANGED
@@ -5,6 +5,23 @@ 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',
@@ -22,6 +39,103 @@ const ComboTrending = async (limit) => {
22
  }
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  /**
26
  * @swagger
27
  * /api/v1/trending/combo:
 
5
 
6
  const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
7
 
8
+ const ComboRecentTrending = async (limit) => {
9
+ const options = {
10
+ method: 'GET',
11
+ url: 'https://randydev-meta-ai.hf.space/combo-recent',
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
  const ComboTrending = async (limit) => {
26
  const options = {
27
  method: 'GET',
 
39
  }
40
  }
41
 
42
+ const ComboSearchTrending = async (query, limit) => {
43
+ const options = {
44
+ method: 'GET',
45
+ url: 'https://randydev-meta-ai.hf.space/combo-search',
46
+ params: {
47
+ query: query,
48
+ limit: limit
49
+ }
50
+ };
51
+ try {
52
+ const response = await axios.request(options);
53
+ return response.data;
54
+ } catch (error) {
55
+ console.error(error);
56
+ return null;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @swagger
62
+ * /api/v1/trending/combo-search:
63
+ * get:
64
+ * summary: Combo Search Trending
65
+ * tags: [Trending]
66
+ * parameters:
67
+ * - in: query
68
+ * name: query
69
+ * required: true
70
+ * description: null
71
+ * schema:
72
+ * type: string
73
+ * - in: query
74
+ * name: limit
75
+ * required: true
76
+ * description: null
77
+ * schema:
78
+ * type: number
79
+ * - in: header
80
+ * name: x-api-key
81
+ * required: true
82
+ * description: API key for authentication
83
+ * schema:
84
+ * type: string
85
+ * responses:
86
+ * 200:
87
+ * description: Success
88
+ */
89
+ TrendingNewRoutes.get("/api/v1/trending/combo", authenticateApiKey, apiLimiter, async (req, res) => {
90
+ const limit = req.query.limit;
91
+ const q = req.query.query;
92
+ if (!q) {
93
+ return res.status(400).json({ error: "Invalid or missing username" });
94
+ }
95
+ try {
96
+ const result = await ComboSearchTrending(q);
97
+ res.json(result);
98
+ } catch (error) {
99
+ res.status(500).json({ error: "Failed to fetch user info" });
100
+ }
101
+ });
102
+
103
+ /**
104
+ * @swagger
105
+ * /api/v1/trending/combo-recent:
106
+ * get:
107
+ * summary: Combo Recent Trending
108
+ * tags: [Trending]
109
+ * parameters:
110
+ * - in: query
111
+ * name: limit
112
+ * required: true
113
+ * description: null
114
+ * schema:
115
+ * type: number
116
+ * - in: header
117
+ * name: x-api-key
118
+ * required: true
119
+ * description: API key for authentication
120
+ * schema:
121
+ * type: string
122
+ * responses:
123
+ * 200:
124
+ * description: Success
125
+ */
126
+ TrendingNewRoutes.get("/api/v1/trending/combo", authenticateApiKey, apiLimiter, async (req, res) => {
127
+ const limit = req.query.limit;
128
+ if (!limit) {
129
+ return res.status(400).json({ error: "Invalid or missing username" });
130
+ }
131
+ try {
132
+ const result = await ComboRecentTrending(limit);
133
+ res.json(result);
134
+ } catch (error) {
135
+ res.status(500).json({ error: "Failed to fetch user info" });
136
+ }
137
+ });
138
+
139
  /**
140
  * @swagger
141
  * /api/v1/trending/combo: