SpaceNinjaServer/src/controllers/api/addFriendImageController.ts

26 lines
746 B
TypeScript
Raw Normal View History

import { RequestHandler } from "express";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
2024-05-28 13:45:06 +02:00
import { getAccountIdForRequest } from "@/src/services/loginService";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
export const addFriendImageController: RequestHandler = async (req, res) => {
2024-05-28 13:45:06 +02:00
const accountId = await getAccountIdForRequest(req);
const json = getJSONfromString<IUpdateGlyphRequest>(String(req.body));
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
ActiveAvatarImageType: json.AvatarImageType
}
);
res.json({});
};
interface IUpdateGlyphRequest {
AvatarImageType: string;
AvatarImage: string;
}