import express from 'express'; import { TiktokDownloader } from '../lib/scrapper.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 * content: * application/json: * schema: * type: object * properties: * success: * type: boolean * data: * type: object * properties: * results: * type: string * description: URL of the downloaded TikTok video * 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; const results = await TiktokDownloader(url); res.json({ results }); } catch (error) { res.status(401).json({ error: error.message }); } }); export { AllDlRoutes };