import { jsonError, jsonResponse } from "../../../common.js";
import { getSaveData } from "../../../roblox-open-cloud.js";

export async function onRequestGet(context: RequestContext) {
  const id = parseInt(context.params.user as string);

  if (isNaN(id)) return jsonError("ID must be a number", 400);

  try {
    return jsonResponse(await getSaveData(context, id));
  } catch {
    return jsonError("Request to Roblox failed", 500);
  }
}