SpaceNinjaServer/src/controllers/custom/addCurrencyController.ts
Sainan 7c59d4fe3f
All checks were successful
Build / build (22) (push) Successful in 33s
Build / build (20) (push) Successful in 57s
Build / build (18) (push) Successful in 1m29s
Build Docker image / docker (push) Successful in 32s
feat(webui): currencies (#931)
Closes #854

Reviewed-on: #931
2025-02-09 07:17:42 -08:00

18 lines
649 B
TypeScript

import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
export const addCurrencyController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const request = req.body as IAddCurrencyRequest;
inventory[request.currency] += request.delta;
await inventory.save();
res.end();
};
interface IAddCurrencyRequest {
currency: "RegularCredits" | "PremiumCredits" | "FusionPoints" | "PrimeTokens";
delta: number;
}