SpaceNinjaServer/src/controllers/stats/uploadController.ts
AMelonInsideLemon 13c68a75c1 feat: initial stats save (#884)
Closes #203

Reviewed-on: http://209.141.38.3/OpenWF/SpaceNinjaServer/pulls/884
Reviewed-by: Sainan <sainan@calamity.inc>
Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
2025-02-06 04:42:59 -08:00

16 lines
648 B
TypeScript

import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getStats, uploadStats } from "@/src/services/statsService";
import { IStatsUpload } from "@/src/types/statTypes";
import { RequestHandler } from "express";
const uploadController: RequestHandler = async (req, res) => {
const payload = getJSONfromString<IStatsUpload>(String(req.body));
const accountId = await getAccountIdForRequest(req);
const playerStats = await getStats(accountId);
await uploadStats(playerStats, payload);
res.status(200).end();
};
export { uploadController };