2023-06-01 17:08:05 -07:00
|
|
|
import { RequestHandler } from "express";
|
2023-12-28 16:24:52 +01:00
|
|
|
import config from "@/config.json";
|
|
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
|
|
import { parseString } from "@/src/helpers/general";
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2023-12-28 16:24:52 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
|
|
export const getCreditsController: RequestHandler = async (req, res) => {
|
2024-01-06 16:26:58 +01:00
|
|
|
if (config.infiniteResources) {
|
2023-12-28 16:24:52 +01:00
|
|
|
res.json({
|
|
|
|
RegularCredits: 999999999,
|
|
|
|
TradesRemaining: 999999999,
|
|
|
|
PremiumCreditsFree: 999999999,
|
|
|
|
PremiumCredits: 999999999
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const accountId = parseString(req.query.accountId);
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2023-12-28 16:24:52 +01:00
|
|
|
const inventory = await getInventory(accountId);
|
|
|
|
res.json({
|
|
|
|
RegularCredits: inventory.RegularCredits,
|
|
|
|
TradesRemaining: inventory.TradesRemaining,
|
|
|
|
PremiumCreditsFree: inventory.PremiumCreditsFree,
|
|
|
|
PremiumCredits: inventory.PremiumCredits
|
|
|
|
});
|
|
|
|
};
|