File size: 4,390 Bytes
e45ae58
 
 
 
 
 
 
d03f93a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e45ae58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d03f93a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bc8883
d03f93a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b29e063
d03f93a
 
 
 
 
 
 
 
 
 
 
 
e45ae58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ad6d02
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import express from 'express';
import axios from 'axios';
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
const TrendingNewRoutes = express.Router();

const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696]; 

const ComboRecentTrending = async (limit) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/combo-recent',
    params: {
      limit: limit
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const ComboTrending = async (limit) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/combo-trending',
    params: {
      limit: limit
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const ComboSearchTrending = async (query, limit) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/combo-search',
    params: {
      query: query,
      limit: limit
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

/**
 * @swagger
 * /api/v1/trending/combo-search:
 *   get:
 *     summary: Combo Search Trending
 *     tags: [Trending]
 *     parameters:
 *       - in: query
 *         name: query
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: query
 *         name: limit
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
TrendingNewRoutes.get("/api/v1/trending/combo-search", authenticateApiKey, apiLimiter, async (req, res) => {
    const limit = req.query.limit;
    const q = req.query.query;
    if (!q) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await ComboSearchTrending(q);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

/**
 * @swagger
 * /api/v1/trending/combo-recent:
 *   get:
 *     summary: Combo Recent Trending
 *     tags: [Trending]
 *     parameters:
 *       - in: query
 *         name: limit
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
TrendingNewRoutes.get("/api/v1/trending/combo-recent", authenticateApiKey, apiLimiter, async (req, res) => {
    const limit = req.query.limit;
    if (!limit) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await ComboRecentTrending(limit);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

/**
 * @swagger
 * /api/v1/trending/combo:
 *   get:
 *     summary: Combo Trending
 *     tags: [Trending]
 *     parameters:
 *       - in: query
 *         name: limit
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
TrendingNewRoutes.get("/api/v1/trending/combo", authenticateApiKey, apiLimiter, async (req, res) => {
    const limit = req.query.limit;
    if (!limit) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await ComboTrending(limit);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

export { TrendingNewRoutes };