SpaceNinjaServer/src/controllers/api/purchaseController.ts

13 lines
616 B
TypeScript
Raw Normal View History

import { RequestHandler } from "express";
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
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const purchaseController: RequestHandler = async (req, res) => {
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
};