SpaceNinjaServer/src/controllers/api/updateThemeController.ts
Sainan 8a29f06207
All checks were successful
Build / build (18) (push) Successful in 52s
Build / build (20) (push) Successful in 1m8s
Build Docker image / docker (push) Successful in 38s
Build / build (22) (push) Successful in 1m26s
chore: use inventory projection for updateTheme (#1302)
Reviewed-on: #1302
2025-03-23 09:06:28 -07:00

24 lines
901 B
TypeScript

import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { RequestHandler } from "express";
import { getInventory } from "@/src/services/inventoryService";
export const updateThemeController: RequestHandler = async (request, response) => {
const accountId = await getAccountIdForRequest(request);
const data = getJSONfromString<IThemeUpdateRequest>(String(request.body));
const inventory = await getInventory(accountId, "ThemeStyle ThemeBackground ThemeSounds");
if (data.Style) inventory.ThemeStyle = data.Style;
if (data.Background) inventory.ThemeBackground = data.Background;
if (data.Sounds) inventory.ThemeSounds = data.Sounds;
await inventory.save();
response.json({});
};
interface IThemeUpdateRequest {
Style?: string;
Background?: string;
Sounds?: string;
}