Greatly reduce repeated code
This commit is contained in:
@ -1,28 +1,18 @@
|
||||
import { insertLogs } from "../../../gcloud.js";
|
||||
import { getBanList, setBanList } from "../../../roblox-open-cloud.js";
|
||||
import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { statsReduction } = context.data.body;
|
||||
|
||||
if (statsReduction && typeof statsReduction !== "number")
|
||||
return new Response('{"error":"Invalid stat reduction"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 400,
|
||||
});
|
||||
return jsonError("Invalid stat reduction", 400);
|
||||
|
||||
const appeal = await context.env.DATA.get(
|
||||
`gameappeal_${context.params.id as string}`,
|
||||
);
|
||||
|
||||
if (!appeal)
|
||||
return new Response('{"error":"Appeal not found"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 404,
|
||||
});
|
||||
if (!appeal) return jsonError("Appeal not found", 400);
|
||||
|
||||
const data = JSON.parse(appeal);
|
||||
const banList = (await getBanList(context)) as {
|
||||
|
@ -1,15 +1,11 @@
|
||||
import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const appealId = context.params.id as string;
|
||||
|
||||
const appeal = await context.env.DATA.get(`gameappeal_${appealId}`);
|
||||
|
||||
if (!appeal)
|
||||
return new Response('{"error":"Appeal not found"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 404,
|
||||
});
|
||||
if (!appeal) return jsonError("Appeal not found", 404);
|
||||
|
||||
const appealData = JSON.parse(appeal);
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
|
||||
export async function onRequest(context: RequestContext) {
|
||||
if (!(context.data.current_user.permissions & (1 << 5)))
|
||||
return new Response('{"error":"Forbidden"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 403,
|
||||
});
|
||||
return jsonError("Forbidden", 403);
|
||||
|
||||
return await context.next();
|
||||
}
|
||||
|
Reference in New Issue
Block a user