Closes #1038 may need some more information about how this endpoint works. had to make a few assumptions. Reviewed-on: #1039 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
26 lines
972 B
TypeScript
26 lines
972 B
TypeScript
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
import { IAlignment } from "@/src/types/inventoryTypes/inventoryTypes";
|
|
import { RequestHandler } from "express";
|
|
|
|
export const updateAlignmentController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const inventory = await getInventory(accountId);
|
|
const body = getJSONfromString<IUpdateAlignmentRequest>(String(req.body));
|
|
inventory.Alignment = {
|
|
Alignment: body.Alignment,
|
|
Wisdom: body.Wisdom
|
|
};
|
|
await inventory.save();
|
|
res.json(inventory.Alignment);
|
|
};
|
|
|
|
interface IUpdateAlignmentRequest {
|
|
Wisdom: number;
|
|
Alignment: number;
|
|
PreviousAlignment: IAlignment;
|
|
AlignmentAction: string; // e.g. "/Lotus/Language/Game/MawCinematicDualChoice"
|
|
KeyChainName: string;
|
|
}
|