SpaceNinjaServer/src/controllers/api/startCollectibleEntryController.ts
Sainan ed9b396cd0
All checks were successful
Build / build (pull_request) Successful in 1m7s
fix: faithful response to startCollectibleEntry
2025-09-19 14:07:40 +02:00

28 lines
1.2 KiB
TypeScript

import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { IIncentiveState } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { RequestHandler } from "express";
export const startCollectibleEntryController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const request = getJSONfromString<IStartCollectibleEntryRequest>(String(req.body));
inventory.CollectibleSeries ??= [];
inventory.CollectibleSeries.push({
CollectibleType: request.target,
Count: 0,
Tracking: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
ReqScans: request.reqScans,
IncentiveStates: request.other
});
await inventory.save();
res.send(`target = ${request.target}key = 0key = 1{"Target":"${request.target}"}`);
};
interface IStartCollectibleEntryRequest {
target: string;
reqScans: number;
other: IIncentiveState[];
}