SpaceNinjaServer/src/controllers/api/startRecipeController.ts

21 lines
766 B
TypeScript
Raw Normal View History

2024-05-28 13:45:06 +02:00
import { getAccountIdForRequest } from "@/src/services/loginService";
2024-01-25 14:49:45 +01:00
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { startRecipe } from "@/src/services/recipeService";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
interface IStartRecipeRequest {
RecipeName: string;
Ids: string[];
}
export const startRecipeController: RequestHandler = async (req, res) => {
const startRecipeRequest = getJSONfromString(String(req.body)) as IStartRecipeRequest;
2024-01-25 14:49:45 +01:00
logger.debug("StartRecipe Request", { startRecipeRequest });
2024-05-28 13:45:06 +02:00
const accountId = await getAccountIdForRequest(req);
2024-01-25 14:49:45 +01:00
const newRecipeId = await startRecipe(startRecipeRequest.RecipeName, accountId);
res.json(newRecipeId);
};