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 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; | |
} | |
} | |
/** | |
* @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 }; |