full tour
This commit is contained in:
32
src/routes/api/tandoor/+server.ts
Normal file
32
src/routes/api/tandoor/+server.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { uploadRecipeWithIngredientsDTO } from '$lib/server/tandoor';
|
||||
|
||||
export async function POST({ request }) {
|
||||
const { recipe } = await request.json();
|
||||
|
||||
if (!recipe) {
|
||||
return json({ error: 'No recipe provided' }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await uploadRecipeWithIngredientsDTO(recipe);
|
||||
|
||||
if (!result.success) {
|
||||
return json({ error: result.error || 'Failed to upload recipe' }, { status: 500 });
|
||||
}
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
message: 'Recipe successfully imported to Tandoor',
|
||||
recipeId: result.recipeId
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Tandoor upload error:', error);
|
||||
return json(
|
||||
{
|
||||
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user