|
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; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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" }); |
|
} |
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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" }); |
|
} |
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 }; |