SpaceNinjaServer/src/controllers/api/tauntHistoryController.ts

20 lines
784 B
TypeScript
Raw Normal View History

import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { ITaunt } from "@/src/types/inventoryTypes/inventoryTypes";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const tauntHistoryController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
2024-09-03 20:21:09 +03:00
if (req.body !== undefined) {
2024-09-03 17:23:42 +03:00
const clientTaunt = JSON.parse(String(req.body)) as ITaunt;
inventory.TauntHistory ??= [];
2024-09-07 23:32:59 +03:00
inventory.TauntHistory.push(clientTaunt);
2024-09-03 17:23:42 +03:00
await inventory.save();
res.end();
2024-09-03 20:21:09 +03:00
} else {
2024-09-03 17:23:42 +03:00
res.json({});
}
};