SpaceNinjaServer/src/controllers/api/setWeaponSkillTreeController.ts
Sainan 04d39ed973
Some checks failed
Build Docker image / docker (push) Waiting to run
Build / build (18) (push) Has been cancelled
Build / build (20) (push) Has been cancelled
Build / build (22) (push) Has been cancelled
chore: use SubdocumentArray.id in some more places (#1400)
Reviewed-on: #1400
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-03-31 04:15:32 -07:00

22 lines
873 B
TypeScript

import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { WeaponTypeInternal } from "@/src/services/itemDataService";
export const setWeaponSkillTreeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, req.query.Category as string);
const payload = getJSONfromString<ISetWeaponSkillTreeRequest>(String(req.body));
const item = inventory[req.query.Category as WeaponTypeInternal].id(req.query.ItemId as string)!;
item.SkillTree = payload.SkillTree;
await inventory.save();
res.end();
};
interface ISetWeaponSkillTreeRequest {
SkillTree: string;
}