From 0f1e5c510fce2e8caa5559f1b5ff766b0c37b42c Mon Sep 17 00:00:00 2001 From: Regalijan Date: Wed, 3 Apr 2024 14:14:11 -0400 Subject: [PATCH] Add save-data endpoint for user history --- functions/api/game-bans/[user]/save-data.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 functions/api/game-bans/[user]/save-data.ts diff --git a/functions/api/game-bans/[user]/save-data.ts b/functions/api/game-bans/[user]/save-data.ts new file mode 100644 index 0000000..5ee0556 --- /dev/null +++ b/functions/api/game-bans/[user]/save-data.ts @@ -0,0 +1,14 @@ +import { jsonError, jsonResponse } from "../../../common.js"; +import { getSaveData } from "../../../roblox-open-cloud.js"; + +export async function onRequestGet(context: RequestContext) { + const id = parseInt(context.params.id as string); + + if (isNaN(id)) return jsonError("ID must be a number", 400); + + try { + return jsonResponse(JSON.stringify(await getSaveData(context, id))); + } catch { + return jsonError("Failed to retrieve save data", 500); + } +}