update
Browse files
index.js
CHANGED
@@ -207,42 +207,6 @@ app.get("/runtime", async (req, res) => {
|
|
207 |
res.send("Running lifetime");
|
208 |
})
|
209 |
|
210 |
-
app.post("/api/v2/api-key-ban", async (req, res) => {
|
211 |
-
const userIdNumber = Number(req.query.user_id);
|
212 |
-
|
213 |
-
if (isNaN(userIdNumber)) {
|
214 |
-
return res.status(400).json({ error: "Invalid or missing user_id" });
|
215 |
-
}
|
216 |
-
|
217 |
-
if (userIdNumber === 0) {
|
218 |
-
return res.status(400).json({ error: "Invalid user_id" });
|
219 |
-
}
|
220 |
-
const existingUser = await ApiKey.findOne({ owner: userIdNumber });
|
221 |
-
|
222 |
-
if (!existingUser) {
|
223 |
-
return res.status(404).json({ error: "API key not found" });
|
224 |
-
}
|
225 |
-
|
226 |
-
if (existingUser.is_banned === true) {
|
227 |
-
return res.status(400).json({ message: "API key is already banned" });
|
228 |
-
}
|
229 |
-
|
230 |
-
const result = await ApiKey.updateOne(
|
231 |
-
{ owner: userIdNumber },
|
232 |
-
{ $set: { is_banned: true } },
|
233 |
-
{ upsert: false }
|
234 |
-
);
|
235 |
-
|
236 |
-
if (result.matchedCount > 0) {
|
237 |
-
res.json({
|
238 |
-
message: "API v2 key successfully banned",
|
239 |
-
owner: userIdNumber
|
240 |
-
});
|
241 |
-
} else {
|
242 |
-
res.status(500).json({ error: "Failed to ban API key" });
|
243 |
-
}
|
244 |
-
});
|
245 |
-
|
246 |
|
247 |
app.post('/api/v2/generate-key', async (req, res) => {
|
248 |
try {
|
@@ -356,19 +320,26 @@ app.post("/api/v1/api-key-unban", async (req, res) => {
|
|
356 |
return res.status(400).json({ error: "sorry only developer" });
|
357 |
}
|
358 |
|
|
|
359 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
360 |
|
361 |
-
if (!existingUser) {
|
362 |
return res.status(404).json({ error: "API key not found" });
|
363 |
}
|
364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
const result = await collection.updateOne(
|
366 |
{ owner: userIdNumber },
|
367 |
{ $set: { is_banned: false } },
|
368 |
{ upsert: false }
|
369 |
);
|
370 |
|
371 |
-
if (result.matchedCount > 0) {
|
372 |
res.json({
|
373 |
message: "API key successfully unbanned",
|
374 |
owner: userIdNumber
|
@@ -425,9 +396,10 @@ app.post("/api/v1/api-key-ban", async (req, res) => {
|
|
425 |
return res.status(400).json({ error: "sorry only developer" });
|
426 |
}
|
427 |
|
|
|
428 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
429 |
|
430 |
-
if (!existingUser) {
|
431 |
return res.status(404).json({ error: "API key not found" });
|
432 |
}
|
433 |
|
@@ -435,13 +407,19 @@ app.post("/api/v1/api-key-ban", async (req, res) => {
|
|
435 |
return res.status(400).json({ message: "API key is already banned" });
|
436 |
}
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
const result = await collection.updateOne(
|
439 |
{ owner: userIdNumber },
|
440 |
{ $set: { is_banned: true } },
|
441 |
{ upsert: false }
|
442 |
);
|
443 |
|
444 |
-
if (result.matchedCount > 0) {
|
445 |
res.json({
|
446 |
message: "API key successfully banned",
|
447 |
owner: userIdNumber
|
|
|
207 |
res.send("Running lifetime");
|
208 |
})
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
app.post('/api/v2/generate-key', async (req, res) => {
|
212 |
try {
|
|
|
320 |
return res.status(400).json({ error: "sorry only developer" });
|
321 |
}
|
322 |
|
323 |
+
const existingUserTwo = await ApiKey.findOne({ owner: userIdNumber });
|
324 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
325 |
|
326 |
+
if (!existingUser || !existingUserTwo) {
|
327 |
return res.status(404).json({ error: "API key not found" });
|
328 |
}
|
329 |
|
330 |
+
const resultTwo = await ApiKey.updateOne(
|
331 |
+
{ owner: userIdNumber },
|
332 |
+
{ $set: { is_banned: false } },
|
333 |
+
{ upsert: false }
|
334 |
+
);
|
335 |
+
|
336 |
const result = await collection.updateOne(
|
337 |
{ owner: userIdNumber },
|
338 |
{ $set: { is_banned: false } },
|
339 |
{ upsert: false }
|
340 |
);
|
341 |
|
342 |
+
if (result.matchedCount > 0 && resultTwo.matchedCount > 0) {
|
343 |
res.json({
|
344 |
message: "API key successfully unbanned",
|
345 |
owner: userIdNumber
|
|
|
396 |
return res.status(400).json({ error: "sorry only developer" });
|
397 |
}
|
398 |
|
399 |
+
const existingUserTwo = await ApiKey.findOne({ owner: userIdNumber });
|
400 |
const existingUser = await collection.findOne({ owner: userIdNumber });
|
401 |
|
402 |
+
if (!existingUser || !existingUserTwo) {
|
403 |
return res.status(404).json({ error: "API key not found" });
|
404 |
}
|
405 |
|
|
|
407 |
return res.status(400).json({ message: "API key is already banned" });
|
408 |
}
|
409 |
|
410 |
+
const resultTwo = await ApiKey.updateOne(
|
411 |
+
{ owner: userIdNumber },
|
412 |
+
{ $set: { is_banned: true } },
|
413 |
+
{ upsert: false }
|
414 |
+
);
|
415 |
+
|
416 |
const result = await collection.updateOne(
|
417 |
{ owner: userIdNumber },
|
418 |
{ $set: { is_banned: true } },
|
419 |
{ upsert: false }
|
420 |
);
|
421 |
|
422 |
+
if (result.matchedCount > 0 && resultTwo.matchedCount > 0) {
|
423 |
res.json({
|
424 |
message: "API key successfully banned",
|
425 |
owner: userIdNumber
|