initial commit

This commit is contained in:
Anika Raemer 2025-09-06 10:56:40 +02:00
commit ee8aedd857
1599 changed files with 652440 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import { Recipe } from "../types/recipe"
/**
* Mock data set with some sample recipes.
* In a real application, this would be fetched from a backend.
*/
export const recipes: Recipe[] = [
{
id: "1",
title: "Spaghetti Bolognese",
ingredients: [
{ name: "Spaghetti", amount: 200, unit: "g" },
{ name: "Ground Beef", amount: 300, unit: "g" },
{ name: "Tomato Sauce", amount: 400, unit: "ml" }
],
instructions: "Cook pasta. Prepare sauce. Mix together. Serve hot.",
photoUrl: "https://source.unsplash.com/400x300/?spaghetti"
}
]

40
backend/src/server.ts Normal file
View file

@ -0,0 +1,40 @@
import express from "express";
import cors from "cors";
import { v4 as uuidv4 } from "uuid";
import { recipes } from "../mock_data/recipes"
import { Recipe } from "../types/recipe"
const app = express();
app.use(cors());
app.use(express.json());
// Routes
app.get("/recipes", (req, res) => res.json(recipes));
app.get("/recipes/:id", (req, res) => {
const recipe = recipes.find(r => r.id === req.params.id);
recipe ? res.json(recipe) : res.status(404).send("Recipe not found");
});
app.post("/recipes", (req, res) => {
const newRecipe: Recipe = { id: uuidv4(), ...req.body };
recipes.push(newRecipe);
res.status(201).json(newRecipe);
});
app.put("/recipes/:id", (req, res) => {
const index = recipes.findIndex(r => r.id === req.params.id);
if (index === -1) return res.status(404).send("Recipe not found");
recipes[index] = { ...recipes[index], ...req.body };
res.json(recipes[index]);
});
app.delete("/recipes/:id", (req, res) => {
recipes = recipes.filter(r => r.id !== req.params.id);
res.status(204).send();
});
app.listen(4000, () => console.log("Server running on http://localhost:4000"));

View file

@ -0,0 +1,15 @@
/**
* Represents a single ingredient in a recipe.
*/
export interface Ingredient {
/** Name of the ingredient (e.g. "Spaghetti") */
name: string
/** Quantity required (e.g. 200, 1.5) */
amount: number
/** Unit of measurement (e.g. "g", "tbsp", "cups").
* Optional for cases like "1 egg".
*/
unit?: string
}

View file

@ -0,0 +1,22 @@
import { Ingredient } from "./ingredient"
/**
* Represents a recipe object in the application.
*/
export interface Recipe {
/** Unique identifier for the recipe */
id: string
/** Title of the recipe */
title: string
/** List of ingredients with amount + unit */
ingredients: Ingredient[]
/** Preparation instructions */
instructions: string
/** Optional image URL for the recipe */
imageUrl?: string
}