Update index.js
Browse files328 unmodified lines329330331332332333334335336337337338339340341342342343344345346347347348349350351352352353354355356357357358359360361362362363364365366367368369370365371372373374118 unmodified lines493494495490496497492493494495496497498499498499500501502503504505506507501508509328 unmodified lines { "title": "Tiktok Downloader", "method": "GET", "example": `${host}/tt?url=`, "example": "${host}/tt?url=" }, { "title": "Facebook Downloader", "method": "GET", "example": `${host}/fb?url=`, "example": "${host}/fb?url=" }, { "title": "Instagram Downloader", "method": "GET", "example": `${host}/ig?url=`, "example": "${host}/ig?url=" }, { "title": "Youtube Downloader", "method": "GET", "example": `${host}/ytdl?url=`, "example": "${host}/ytdl?url=" }, { "title": "Youtube Search", "method": "GET", "example": `${host}/ytsearch?q=`, "example": "${host}/ytsearch?q=" }, { "title": "Pinterest Downloader", "method": "GET", "example": `${host}/pindl?url=`, "example": "${host}/pindl?url=" }, { "title": "Mediafire Downloader", "method": "GET", "example": `${host}/mediafire?url=`, "example": "${host}/mediafire?url=" }, { "title": "Mega Downloader", "method": "POST", "example": "${host}/mega", "body": "JSON.stringify({ \"url\": \"example.com\" })" } ]})})}) .get('/yt', async (req, res) => { const host = 'https://' + req.get('host'); try {118 unmodified lines return res.json({ message: e.message }); } }) .get('/mega', async (req,res) => { .post('/mega', async (req, res) => { try { let {url} = req.query if (!/https:\/\/mega\.nz\/file\/[a-zA-Z0-9]{8}#[a-zA-Z0-9-_]{43}/.test(url)) { return res.json({ message: 'Invalid URL' }); } console.log(url) } catch (e) { console.log(e); return res.json({ message: e.message }); let { url } = req.body; if (!/https:\/\/mega\.nz\/file\/[a-zA-Z0-9]{8}#[a-zA-Z0-9-_]{43}/.test(url)) { return res.json({ message: 'Invalid URL' }); } console.log(url); return res.json({ message: 'URL is valid' }); } catch (e) { console.log(e); return res.json({ message: e.message }); } })}); .listen(7860, () => console.log('App running on port 7860'));index.js+25-18