SpaceNinjaServer/src/controllers/custom/addItemsController.ts
Sainan 8c85cdcd1d
All checks were successful
Build / build (push) Successful in 1m0s
Build Docker image / docker-amd64 (push) Successful in 50s
Build Docker image / docker-arm64 (push) Successful in 1m0s
feat(webui): "add maxed" for mods (#2387)
Closes #2382

Reviewed-on: #2387
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:18:24 -07:00

21 lines
727 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, request.Fingerprint, true);
}
await inventory.save();
res.end();
};
interface IAddItemRequest {
ItemType: string;
ItemCount: number;
Fingerprint?: string;
}