SpaceNinjaServer/src/controllers/api/giveKeyChainTriggeredItemsController.ts
Sainan 0a8f2b9559
All checks were successful
Build / build (18) (push) Successful in 43s
Build / build (20) (push) Successful in 1m12s
Build / build (22) (push) Successful in 1m4s
Build / build (18) (pull_request) Successful in 44s
Build / build (20) (pull_request) Successful in 1m14s
Build / build (22) (pull_request) Successful in 1m1s
chore: fix controllers exporting non-RequestHandler things
2025-04-05 03:36:33 +02:00

18 lines
787 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 { giveKeyChainItem } from "@/src/services/questService";
import { IKeyChainRequest } from "@/src/types/requestTypes";
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);
};