Update index.js
Browse files131 unmodified lines132133134135136137138139140141135136137138139143144140141142146147148149150151152153154143144145146147148149150151152153154155156157158159160156161162131 unmodified lines } }) .get('/megajs', async (req, res) => { try { let { url } = req.query; const match = url.match(megaRegex); if (!match) return res.json({ message: 'Invalid URL' });
const id = match[1]; const query = match[2] || ''; // Jika tidak ada query, gunakan string kosong try { let { url } = req.query; const match = url.match(megaRegex); if (!match) return res.json({ message: 'Invalid URL' });
const file = File.fromURL(`https://mega.nz/file/${id}#${query}`); await file.loadAttributes(); const id = match[1]; const query = match[2] || ''; // Jika tidak ada query, gunakan string kosong
const data = await file.downloadBuffer(); res.json({ name: file.name, // Nama file size: file.size, // Ukuran file dalam byte contents: data.toString() // Konten file dalam format string }); } catch (error) { console.error(error); res.json({ message: error.message }); let fileURL = `https://mega.nz/file/${id}`; if (query) { fileURL += `#${query}`; }
const file = File.fromURL(fileURL); await file.loadAttributes();
const data = await file.downloadBuffer(); res.json({ name: file.name, // Nama file size: file.size, // Ukuran file dalam byte contents: data.toString() // Konten file dalam format string }); } catch (error) { console.error(error); res.json({ message: error.message }); } })}) .listen(7860, () => console.log('App running on port 7860'));index.js+24-19