SpaceNinjaServer/src/controllers/api/updateAlignmentController.ts
Sainan c971a484ef feat: updateAlignment (#1039)
Closes #1038

may need some more information about how this endpoint works. had to make a few assumptions.

Reviewed-on: OpenWF/SpaceNinjaServer#1039
Co-authored-by: Sainan <sainan@calamity.inc>
Co-committed-by: Sainan <sainan@calamity.inc>
2025-02-28 12:36:49 -08:00

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;
}