forked from OpenWF/SpaceNinjaServer
Closes #1621 Reviewed-on: OpenWF/SpaceNinjaServer#1634 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
21 lines
998 B
TypeScript
21 lines
998 B
TypeScript
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
import { addLoreFragmentScans, addShipDecorations, getInventory } from "@/src/services/inventoryService";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
import { ILoreFragmentScan, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
|
import { RequestHandler } from "express";
|
|
|
|
export const giveShipDecoAndLoreFragmentController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const inventory = await getInventory(accountId, "LoreFragmentScans ShipDecorations");
|
|
const data = getJSONfromString<IGiveShipDecoAndLoreFragmentRequest>(String(req.body));
|
|
addLoreFragmentScans(inventory, data.LoreFragmentScans);
|
|
addShipDecorations(inventory, data.ShipDecorations);
|
|
await inventory.save();
|
|
res.end();
|
|
};
|
|
|
|
interface IGiveShipDecoAndLoreFragmentRequest {
|
|
LoreFragmentScans: ILoreFragmentScan[];
|
|
ShipDecorations: ITypeCount[];
|
|
}
|