2023-06-01 17:08:05 -07:00
|
|
|
import { RequestHandler } from "express";
|
2024-05-15 21:55:59 +02:00
|
|
|
import { config } from "@/src/services/configService";
|
2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2023-12-28 16:24:52 +01:00
|
|
|
import { getInventory } from "@/src/services/inventoryService";
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2023-12-28 16:24:52 +01:00
|
|
|
export const getCreditsController: RequestHandler = async (req, res) => {
|
2025-01-04 01:04:00 +01:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2024-05-31 13:17:10 +02:00
|
|
|
|
2023-12-28 16:24:52 +01:00
|
|
|
const inventory = await getInventory(accountId);
|
2024-12-22 00:34:19 +01:00
|
|
|
|
|
|
|
const response = {
|
2023-12-28 16:24:52 +01:00
|
|
|
RegularCredits: inventory.RegularCredits,
|
|
|
|
TradesRemaining: inventory.TradesRemaining,
|
|
|
|
PremiumCreditsFree: inventory.PremiumCreditsFree,
|
|
|
|
PremiumCredits: inventory.PremiumCredits
|
2024-12-22 00:34:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if (config.infiniteCredits) {
|
|
|
|
response.RegularCredits = 999999999;
|
|
|
|
}
|
|
|
|
if (config.infinitePlatinum) {
|
|
|
|
response.PremiumCreditsFree = 999999999;
|
|
|
|
response.PremiumCredits = 999999999;
|
|
|
|
}
|
|
|
|
|
|
|
|
res.json(response);
|
2023-12-28 16:24:52 +01:00
|
|
|
};
|