SpaceNinjaServer/src/controllers/custom/addItemsController.ts
Sainan f7906c91e3
Some checks failed
Build / build (push) Has been cancelled
Build Docker image / docker (push) Has been cancelled
fix: ignore purchaseQuantity for webui add items (#1944)
Closes #1942

Reviewed-on: #1944
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-05-01 13:54:04 -07:00

20 lines
691 B
TypeScript

import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory, addItem } from "@/src/services/inventoryService";
import { RequestHandler } from "express";
export const addItemsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const requests = req.body as IAddItemRequest[];
const inventory = await getInventory(accountId);
for (const request of requests) {
await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, undefined, true);
}
await inventory.save();
res.end();
};
interface IAddItemRequest {
ItemType: string;
ItemCount: number;
}