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[];
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
|
|
export const startRecipeController: RequestHandler = async (req, res) => {
|
|
|
|
const startRecipeRequest = getJSONfromString(req.body.toString()) as IStartRecipeRequest;
|
|
|
|
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);
|
|
|
|
};
|