2025-02-06 04:42:59 -08:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2025-02-11 21:27:05 -08:00
|
|
|
import { getStats, updateStats } from "@/src/services/statsService";
|
|
|
|
import { IStatsUpdate } from "@/src/types/statTypes";
|
2023-06-01 17:52:59 -07:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
|
2025-02-06 04:42:59 -08:00
|
|
|
const uploadController: RequestHandler = async (req, res) => {
|
2025-02-11 21:27:05 -08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
const { PS, ...payload } = getJSONfromString<IStatsUpdate>(String(req.body));
|
2025-02-06 04:42:59 -08:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const playerStats = await getStats(accountId);
|
2025-02-11 21:27:05 -08:00
|
|
|
await updateStats(playerStats, payload);
|
2023-09-11 13:20:07 +02:00
|
|
|
res.status(200).end();
|
2023-06-01 17:52:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export { uploadController };
|