SpaceNinjaServer/src/controllers/api/giveKeyChainTriggeredItemsController.ts
Ordis 9f0be223e6
All checks were successful
Build / build (20) (push) Successful in 36s
Build / build (18) (push) Successful in 1m1s
Build / build (22) (push) Successful in 1m4s
Build Docker image / docker (push) Successful in 34s
fix: returning givekeychainitem response
2025-02-21 15:46:09 +01:00

24 lines
883 B
TypeScript

import { RequestHandler } from "express";
import { parseString } from "@/src/helpers/general";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService";
import { IGroup } from "@/src/types/loginTypes";
import { giveKeyChainItem } from "@/src/services/questService";
export const giveKeyChainTriggeredItemsController: RequestHandler = async (req, res) => {
const accountId = parseString(req.query.accountId);
const keyChainInfo = getJSONfromString<IKeyChainRequest>((req.body as string).toString());
const inventory = await getInventory(accountId);
const inventoryChanges = await giveKeyChainItem(inventory, keyChainInfo);
await inventory.save();
res.send(inventoryChanges);
};
export interface IKeyChainRequest {
KeyChain: string;
ChainStage: number;
Groups?: IGroup[];
}