SpaceNinjaServer/src/controllers/api/setEquippedInstrumentController.ts

18 lines
689 B
TypeScript
Raw Normal View History

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