File size: 3,810 Bytes
fc3dc85
f49d9a4
 
fc3dc85
 
 
 
 
 
 
 
 
 
 
 
 
ae7bd46
 
 
 
 
 
 
fc3dc85
 
 
 
 
ae7bd46
 
 
 
 
 
fc3dc85
 
 
 
c61dcbf
 
 
 
 
93067a0
 
fc3dc85
c61dcbf
fc3dc85
 
 
2742468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import express from 'express';
import { TiktokDownloader, XnxxDownloader } from '../lib/scrapper.js';
import { facebookdl } from '../lib/facebook.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: q
 *         required: true
 *         description: nothing
 *         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 q = 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/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 };