2025-02-06 04:42:59 -08:00
|
|
|
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";
|
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) => {
|
|
|
|
const payload = getJSONfromString<IStatsUpload>(String(req.body));
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const playerStats = await getStats(accountId);
|
|
|
|
await uploadStats(playerStats, payload);
|
2023-09-11 13:20:07 +02:00
|
|
|
res.status(200).end();
|
2023-06-01 17:52:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export { uploadController };
|