| 
									
										
										
										
											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) => { | 
					
						
							| 
									
										
										
										
											2024-06-24 12:37:28 +02:00
										 |  |  |     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); | 
					
						
							|  |  |  | }; |