SpaceNinjaServer/src/controllers/api/setEquippedInstrumentController.ts
Sainan d9eec90d3c
All checks were successful
Build / build (18) (push) Successful in 45s
Build / build (22) (push) Successful in 1m5s
Build / build (20) (push) Successful in 1m2s
Build / build (18) (pull_request) Successful in 47s
Build / build (20) (pull_request) Successful in 1m7s
Build / build (22) (pull_request) Successful in 1m1s
chore: use updateOne for simple inventory field setters
2025-03-16 13:58:44 +01: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;
}