SpaceNinjaServer/src/controllers/api/purchaseController.ts

12 lines
555 B
TypeScript
Raw Normal View History

2024-05-28 13:45:06 +02:00
import { getAccountIdForRequest } from "@/src/services/loginService";
import { toPurchaseRequest } from "@/src/helpers/purchaseHelpers";
import { handlePurchase } from "@/src/services/purchaseService";
2023-05-19 15:22:48 -03:00
import { Request, Response } from "express";
export const purchaseController = async (req: Request, res: Response) => {
const purchaseRequest = toPurchaseRequest(JSON.parse(String(req.body)));
2024-05-28 13:45:06 +02:00
const accountId = await getAccountIdForRequest(req);
const response = await handlePurchase(purchaseRequest, accountId);
res.json(response);
2023-05-19 15:22:48 -03:00
};