SpaceNinjaServer/src/controllers/api/setEquippedInstrumentController.ts
Sainan 05356af9bd
Some checks failed
Build Docker image / docker (push) Waiting to run
Build / build (18) (push) Has been cancelled
Build / build (22) (push) Has been cancelled
Build / build (20) (push) Has been cancelled
chore: use updateOne for simple inventory field setters (#1211)
e.g. changing syndicate pledge now takes ~6 ms instead of ~84 ms.

Reviewed-on: #1211
2025-03-16 08:16:27 -07:00

25 lines
732 B
TypeScript

import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
export const setEquippedInstrumentController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const body = getJSONfromString<ISetEquippedInstrumentRequest>(String(req.body));
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
EquippedInstrument: body.Instrument
}
);
res.end();
};
interface ISetEquippedInstrumentRequest {
Instrument: string;
}