2025-01-11 12:54:32 +01:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
2025-03-16 13:58:44 +01:00
|
|
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
2025-01-11 12:54:32 +01:00
|
|
|
|
|
|
|
export const setEquippedInstrumentController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2025-01-24 14:27:10 +01:00
|
|
|
const body = getJSONfromString<ISetEquippedInstrumentRequest>(String(req.body));
|
2025-03-16 13:58:44 +01:00
|
|
|
|
|
|
|
await Inventory.updateOne(
|
|
|
|
{
|
|
|
|
accountOwnerId: accountId
|
|
|
|
},
|
|
|
|
{
|
|
|
|
EquippedInstrument: body.Instrument
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2025-01-11 12:54:32 +01:00
|
|
|
res.end();
|
|
|
|
};
|
|
|
|
|
|
|
|
interface ISetEquippedInstrumentRequest {
|
|
|
|
Instrument: string;
|
|
|
|
}
|