SpaceNinjaServer/src/controllers/api/addFriendImageController.ts
2025-08-25 06:51:16 +02:00

26 lines
760 B
TypeScript

import type { RequestHandler } from "express";
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
export const addFriendImageController: RequestHandler = async (req, res) => {
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;
}