import express from 'express'; import { TiktokDownloader, XnxxDownloader } from '../lib/scrapper.js'; import { facebookdl } from '../lib/facebook.js'; import { savefrom } from '../lib/savefrom.js'; import { authenticateApiKey, apiLimiter } from '../middleware/midware.js'; const AllDlRoutes = express.Router(); /** * @swagger * /api/v1/dl/tiktok: * get: * summary: Tiktok Downloader * tags: [ALL-Downloader] * parameters: * - in: query * name: url * required: true * description: The URL of the TikTok video to be processed * schema: * type: string * - in: header * name: x-api-key * required: true * description: API key for authentication * schema: * type: string * responses: * 200: * description: Success * 400: * description: Bad Request (e.g., missing or invalid URL) * 401: * description: Unauthorized (e.g., missing or invalid API key) * 500: * description: Internal Server Error */ AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req, res) => { try { const url = req.query.url; if (!url) { return res.status(400).json({ error: "URL parameter is required." }); } const results = await TiktokDownloader(url); res.json({ results }); } catch (error) { res.status(500).json({ error: error.message }); } }); /** * @swagger * /api/v1/dl/fb: * get: * summary: FB Downloader * tags: [ALL-Downloader] * parameters: * - in: query * name: url * required: true * description: null * schema: * type: string * - in: header * name: x-api-key * required: true * description: API key for authentication * schema: * type: string * responses: * 200: * description: Success * 400: * description: Bad Request (e.g., missing or invalid url) * 401: * description: Unauthorized (e.g., missing or invalid API key) * 500: * description: Internal Server Error */ AllDlRoutes.get('/api/v1/dl/fb', authenticateApiKey, apiLimiter, async (req, res) => { try { const url = req.query.url; if (!url) { return res.status(400).json({ error: "url parameter is required." }); } const results = await facebookdl(url); res.json({ results }); } catch (error) { res.status(500).json({ error: error.message }); } }); /** * @swagger * /api/v1/dl/savefrom: * get: * summary: Savefrom Downloader * tags: [ALL-Downloader] * parameters: * - in: query * name: url * required: true * description: null * schema: * type: string * - in: header * name: x-api-key * required: true * description: API key for authentication * schema: * type: string * responses: * 200: * description: Success * 400: * description: Bad Request (e.g., missing or invalid url) * 401: * description: Unauthorized (e.g., missing or invalid API key) * 500: * description: Internal Server Error */ AllDlRoutes.get('/api/v1/dl/savefrom', authenticateApiKey, apiLimiter, async (req, res) => { try { const url = req.query.url; if (!url) { return res.status(400).json({ error: "url parameter is required." }); } const results = await savefrom(url); res.json({ results }); } catch (error) { res.status(500).json({ error: error.message }); } }); /** * @swagger * /api/v1/dl/xnxx: * get: * summary: Xnxx Downloader * tags: [ALL-Downloader] * parameters: * - in: query * name: q * required: true * description: The search of the Xnxx video to be processed * schema: * type: string * - in: header * name: x-api-key * required: true * description: API key for authentication * schema: * type: string * responses: * 200: * description: Success * 400: * description: Bad Request (e.g., missing or invalid q) * 401: * description: Unauthorized (e.g., missing or invalid API key) * 500: * description: Internal Server Error */ AllDlRoutes.get('/api/v1/dl/xnxx', authenticateApiKey, apiLimiter, async (req, res) => { try { const q = req.query.q; if (!q) { return res.status(400).json({ error: "q parameter is required." }); } const results = await XnxxDownloader(q); res.json({ results }); } catch (error) { res.status(500).json({ error: error.message }); } }); export { AllDlRoutes };