2023-09-10 00:10:21 +04:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2023-09-06 14:02:54 +04:00
|
|
|
import { upgradeMod } from "@/src/services/inventoryService";
|
2023-09-10 00:10:21 +04:00
|
|
|
import { IArtifactsRequest } from "@/src/types/requestTypes";
|
2023-09-06 14:02:54 +04:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
|
|
const artifactsController: RequestHandler = async (req, res) => {
|
2024-05-28 13:45:06 +02:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2023-09-06 14:02:54 +04:00
|
|
|
|
|
|
|
try {
|
2023-09-10 00:10:21 +04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
|
|
|
const artifactsData = getJSONfromString(req.body.toString()) as IArtifactsRequest;
|
2023-09-06 14:02:54 +04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
2023-09-10 00:10:21 +04:00
|
|
|
const upgradeModId = await upgradeMod(artifactsData, accountId);
|
2023-09-06 14:02:54 +04:00
|
|
|
res.send(upgradeModId);
|
|
|
|
} catch (err) {
|
|
|
|
console.error("Error parsing JSON data:", err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export { artifactsController };
|