2025-02-22 11:10:52 -08:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
2025-04-05 06:52:35 -07:00
|
|
|
import { addStartingGear, getInventory } from "@/src/services/inventoryService";
|
2025-02-22 11:10:52 -08:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2025-04-05 06:52:35 -07:00
|
|
|
import { TPartialStartingGear } from "@/src/types/inventoryTypes/inventoryTypes";
|
2025-02-22 11:10:52 -08:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
|
|
|
|
export const giveStartingGearController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const startingGear = getJSONfromString<TPartialStartingGear>(String(req.body));
|
|
|
|
const inventory = await getInventory(accountId);
|
|
|
|
|
|
|
|
const inventoryChanges = await addStartingGear(inventory, startingGear);
|
|
|
|
await inventory.save();
|
|
|
|
|
|
|
|
res.send(inventoryChanges);
|
|
|
|
};
|