Spaces:
Sleeping
Sleeping
Closure-RI
commited on
Update index.js
Browse files
index.js
CHANGED
@@ -10,7 +10,7 @@ import nodeID3 from 'node-id3';
|
|
10 |
import ytdl from 'ytdl-core';
|
11 |
import FormData from 'form-data';
|
12 |
import fetch from 'node-fetch';
|
13 |
-
|
14 |
const require = createRequire(import.meta.url);
|
15 |
const fs = require('fs');
|
16 |
const path = require('path');
|
@@ -49,6 +49,8 @@ const agent = new https.Agent({
|
|
49 |
app.use('/temp', express.static(tempDir));
|
50 |
app.use(express.json());
|
51 |
app.use(express.raw({ type: '*/*', limit: '10mb' })); // Untuk menangani buffer dan data binary
|
|
|
|
|
52 |
|
53 |
app.all('/axios/:method/*', async (req, res) => {
|
54 |
const { method } = req.params;
|
@@ -120,6 +122,61 @@ app.get("/", (req, res) => {
|
|
120 |
res.send(keluaran);
|
121 |
});
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
// Fungsi untuk menghasilkan IP acak
|
124 |
const generateRandomIP = () => {
|
125 |
const octet = () => Math.floor(Math.random() * 256);
|
|
|
10 |
import ytdl from 'ytdl-core';
|
11 |
import FormData from 'form-data';
|
12 |
import fetch from 'node-fetch';
|
13 |
+
import mime from "mime-types";
|
14 |
const require = createRequire(import.meta.url);
|
15 |
const fs = require('fs');
|
16 |
const path = require('path');
|
|
|
49 |
app.use('/temp', express.static(tempDir));
|
50 |
app.use(express.json());
|
51 |
app.use(express.raw({ type: '*/*', limit: '10mb' })); // Untuk menangani buffer dan data binary
|
52 |
+
app.use(express.urlencoded({ extended: true }));
|
53 |
+
|
54 |
|
55 |
app.all('/axios/:method/*', async (req, res) => {
|
56 |
const { method } = req.params;
|
|
|
122 |
res.send(keluaran);
|
123 |
});
|
124 |
|
125 |
+
app.post("/eval", async (req, res) => {
|
126 |
+
const { code } = req.body;
|
127 |
+
const { responseType = "text" } = req.query;
|
128 |
+
|
129 |
+
let _return;
|
130 |
+
try {
|
131 |
+
_return = /await/i.test(code)
|
132 |
+
? await eval(`(async () => { ${code} })()`)
|
133 |
+
: eval(code);
|
134 |
+
} catch (err) {
|
135 |
+
_return = err.toString();
|
136 |
+
}
|
137 |
+
|
138 |
+
// Handle Buffer atau Base64
|
139 |
+
if (Buffer.isBuffer(_return) || typeof _return === "string" && _return.startsWith("data:")) {
|
140 |
+
const buffer = Buffer.isBuffer(_return)
|
141 |
+
? _return
|
142 |
+
: Buffer.from(_return.split(",")[1], "base64");
|
143 |
+
|
144 |
+
const fileType = await fileTypeFromBuffer(buffer);
|
145 |
+
const mimeType = fileType ? fileType.mime : "application/octet-stream";
|
146 |
+
const ext = fileType ? fileType.ext : "bin";
|
147 |
+
const filename = `Nex - ${Date.now()}.${ext}`;
|
148 |
+
|
149 |
+
res.setHeader("Content-Type", mimeType);
|
150 |
+
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
|
151 |
+
return res.send(buffer);
|
152 |
+
}
|
153 |
+
|
154 |
+
// Handle respon berdasarkan responseType
|
155 |
+
switch (responseType) {
|
156 |
+
case "json":
|
157 |
+
try {
|
158 |
+
const jsonFormatted = typeof _return === "string" ? JSON.parse(_return) : _return;
|
159 |
+
return res.json(jsonFormatted);
|
160 |
+
} catch (err) {
|
161 |
+
return res.json({ error: "Invalid JSON format", result: _return });
|
162 |
+
}
|
163 |
+
|
164 |
+
case "file":
|
165 |
+
const filePath = path.join(__dirname, `Nex - ${Date.now()}.txt`);
|
166 |
+
fs.writeFileSync(filePath, _return.toString());
|
167 |
+
return res.download(filePath, () => fs.unlinkSync(filePath));
|
168 |
+
|
169 |
+
case "text":
|
170 |
+
default:
|
171 |
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
172 |
+
return res.send(_return.toString());
|
173 |
+
}
|
174 |
+
});
|
175 |
+
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
|
180 |
// Fungsi untuk menghasilkan IP acak
|
181 |
const generateRandomIP = () => {
|
182 |
const octet = () => Math.floor(Math.random() * 256);
|