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 query to be processed by the GPT OLD. | |
* schema: | |
* type: string | |
* responses: | |
* 200: | |
* description: Success | |
*/ | |
AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req, res) => { | |
try { | |
const url = req.query.url; | |
const response = await TiktokDownloader(url); | |
res.json(response); | |
} catch (error) { | |
res.status(401).json({ error: error.message }); | |
} | |
}); | |
export { AllDlRoutes }; |