Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
car-crushers-portal/functions/api/game-appeals/metadata.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22 lines (15 sloc)
660 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { jsonError, jsonResponse } from "../../common.js"; | |
import precheck from "./precheck.js"; | |
export async function onRequestPost(context: RequestContext) { | |
if ( | |
context.request.headers.get("rbx-auth") !== | |
context.env.ROBLOX_APPEALS_TOKEN | |
) | |
return jsonError("Unauthorized", 401); | |
const { id }: { id: any } = context.data.body; | |
if (typeof id !== "number") return jsonError("Invalid user id", 400); | |
const precheckData = await precheck(context, id); | |
if (precheckData.error) return jsonError(precheckData.error, 500); | |
const { can_appeal, reason } = precheckData; | |
return jsonResponse(JSON.stringify({ can_appeal, reason })); | |
} |