SpaceNinjaServer/src/controllers/api/giveStartingGearController.ts
Sainan 49edebc1eb
All checks were successful
Build / build (20) (push) Successful in 43s
Build / build (18) (push) Successful in 1m16s
Build Docker image / docker (push) Successful in 35s
Build / build (22) (push) Successful in 1m19s
chore: fix controllers exporting non-RequestHandler things (#1468)
I'm surprised JavaScript allows circular includes, but they still don't feel good.

Reviewed-on: #1468
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-04-05 06:52:35 -07:00

17 lines
757 B
TypeScript

import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { addStartingGear, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { TPartialStartingGear } from "@/src/types/inventoryTypes/inventoryTypes";
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);
};