File size: 2,619 Bytes
fc3dc85 1bd12df fc3dc85 ae7bd46 fc3dc85 ae7bd46 fc3dc85 c61dcbf 93067a0 fc3dc85 c61dcbf fc3dc85 1bd12df fc3dc85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import express from 'express';
import { TiktokDownloader, XnxxDownloader } 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
* 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/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 }; |