SpaceNinjaServerOnlyGit/src/controllers/custom/popArchonCrystalUpgradeController.ts
Sainan 04d39ed973 chore: use SubdocumentArray.id in some more places (#1400)
Reviewed-on: OpenWF/SpaceNinjaServer#1400
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-03-31 04:15:32 -07:00

18 lines
713 B
TypeScript

import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
export const popArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const suit = inventory.Suits.id(req.query.oid as string);
if (suit && suit.ArchonCrystalUpgrades) {
suit.ArchonCrystalUpgrades = suit.ArchonCrystalUpgrades.filter(
x => x.UpgradeType != (req.query.type as string)
);
await inventory.save();
res.end();
}
res.status(400).end();
};