chore: optimise creditsController #2359

Merged
Sainan merged 1 commits from faster-credits into main 2025-06-30 11:05:51 -07:00
Showing only changes of commit 8683d4e85d - Show all commits

View File

@ -4,9 +4,15 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService"; import { getInventory } from "@/src/services/inventoryService";
export const creditsController: RequestHandler = async (req, res) => { export const creditsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const inventory = (
await Promise.all([
const inventory = await getInventory(accountId, "RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits"); getAccountIdForRequest(req),
getInventory(
req.query.accountId as string,
"RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits"
)
])
)[1];
const response = { const response = {
RegularCredits: inventory.RegularCredits, RegularCredits: inventory.RegularCredits,