Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Recipe Website API

Backend REST API for the Recipe Website project. Built with Node.js, Express.js, and SQLite.

Your job: build the frontend that consumes this API. This document describes everything you need to know: how to install, run, and call every endpoint.


Fonctionnalites du site

Consultation publique (sans compte)

  • Parcourir les recettes : voir toutes les recettes avec leur cuisine, categories dietetiques et objectifs
  • Detail d'une recette : consulter les ingredients, les etapes de preparation, les informations dietetiques, les objectifs et les allergenes (deduits automatiquement des ingredients)
  • Filtrer les recettes :
    • Par type de cuisine (Italienne, Asiatique, etc.)
    • Par objectif (Perte de poids, Riche en proteines, etc.)
    • Par exclusion d'allergene (ex : afficher uniquement les recettes sans gluten)
  • Consulter les cuisines : liste des cuisines disponibles avec leurs recettes associees
  • Consulter les ingredients : liste des ingredients avec leurs allergenes et les recettes qui les utilisent
  • Lire les avis : voir les notes et commentaires laisses sur chaque recette

Gestion de compte utilisateur

  • Inscription : creer un compte avec nom d'utilisateur, email et mot de passe
  • Connexion / Deconnexion : authentification par session (cookies)
  • Profil : consulter, modifier ou supprimer son compte
  • Changer son mot de passe

Creation et gestion de recettes (utilisateur connecte)

  • Creer une recette : titre, description, image, type de cuisine
  • Gerer les ingredients : ajouter ou retirer des ingredients d'une recette
  • Gerer les etapes : ajouter, modifier ou supprimer les instructions de preparation
  • Gerer les categories dietetiques : associer ou retirer des classifications (Vegetarien, Sans gluten, Cetogene, etc.)
  • Gerer les objectifs : associer ou retirer des objectifs (Rapide et facile, Economique, etc.)
  • Modifier le titre d'une recette
  • Supprimer une recette (et toutes ses donnees associees)

Un utilisateur ne peut modifier/supprimer que ses propres recettes. Les administrateurs peuvent modifier n'importe quelle recette.

Favoris et evaluations (utilisateur connecte)

  • Ajouter/retirer une recette des favoris
  • Consulter ses recettes favorites
  • Noter une recette de 1 a 5 etoiles avec un commentaire optionnel
  • Modifier ou supprimer sa propre note
  • Consulter ses evaluations

Administration (administrateur uniquement)

  • Gerer les cuisines : creer, modifier ou supprimer un type de cuisine. La suppression d'une cuisine reaffecte automatiquement ses recettes a "Internationale"
  • Gerer les allergenes des ingredients : associer ou retirer un allergene d'un ingredient. Ces associations se repercutent automatiquement sur toutes les recettes utilisant cet ingredient

Table of Contents

  1. Fonctionnalites du site
  2. Quick Start
  3. Project Structure
  4. Database Schema
  5. Authentication
  6. Connecting from a Frontend
  7. API Reference
  8. Reference ID Tables
  9. Testing with Postman
  10. Sample Data

Quick Start

Prerequisites

  • Node.js >= 16
  • npm (comes with Node.js)

Installation

# 1. Install dependencies
npm install

# 2. Build the database (creates database/recettes.db with sample data)
node database/setup-database.js

# 3. Start the server in development mode (auto-reload on file changes)
npm run dev

The API will be available at http://localhost:3050.

Available Scripts

Command Description
npm run dev Start dev server with nodemon (auto-reload)
npm start Start production server
node database/setup-database.js Rebuild the database from scratch

Environment Variables

The .env file contains:

NODE_ENV=development
PORT=3050
DATABASE_PATH=./database/recettes.db

You can change PORT if 3050 is already in use.


Project Structure

RecipeWebsite - Project/
  app.js                  # Express application entry point
  package.json
  .env.example            # Environment variables template
  README.md               # This file

  config/
    database.js           # SQLite connection (singleton)

  database/
    create_tables.sql     # Full schema (all tables)
    insert_data.sql       # Sample data
    setup-database.js     # Run this to rebuild the DB
    recettes.db           # SQLite database file (generated, not in git)

  middleware/
    auth.js               # authenticate, checkRecipeOwnership, requireAdmin
    errorHandler.js       # Global error handler

  models/
    User.js               # User model (register, login, favorites, ratings)

  controllers/
    userController.js     # User business logic

  routes/
    recipes.js            # /api/recipes endpoints
    cuisines.js           # /api/cuisines endpoints
    ingredients.js        # /api/ingredients endpoints
    users.js              # /api/users endpoints

Database Schema

Entity-Relationship Diagram (text)

Cuisines ──────< Recipes >────── Users
                   │
         ┌─────────┼──────────┐
         │         │          │
   RecipeGoals  RecipeDietary RecipeIngredients >── Ingredients
         │         │                                    │
       Goals  DietaryInfo                     IngredientAllergies
                                                        │
                                                 AllergiesInformation

Recipes ──< RecipeInstructions
Recipes ──< RecipeRatings >── Users
Recipes ──< UserFavorites >── Users

Tables

Cuisines

Column Type Notes
cuisine_id INTEGER PRIMARY KEY
name TEXT NOT NULL

Goals

Column Type Notes
goal_id INTEGER PRIMARY KEY
name TEXT NOT NULL

DietaryInformation

Column Type Notes
diet_id INTEGER PRIMARY KEY
name TEXT NOT NULL

AllergiesInformation

Column Type Notes
allergy_id INTEGER PRIMARY KEY
name TEXT NOT NULL

Ingredients

Column Type Notes
ingredient_id INTEGER PRIMARY KEY
name TEXT NOT NULL
unit TEXT e.g. "grammes", "unites"

Users

Column Type Notes
user_id INTEGER PRIMARY KEY, AUTOINCREMENT
username TEXT NOT NULL, UNIQUE
email TEXT NOT NULL, UNIQUE
password_hash TEXT NOT NULL (bcrypt)
first_name TEXT nullable
last_name TEXT nullable
created_at DATETIME default CURRENT_TIMESTAMP
updated_at DATETIME default CURRENT_TIMESTAMP
is_admin INTEGER 0 or 1, default 0

Recipes

Column Type Notes
recipe_id INTEGER PRIMARY KEY
title TEXT NOT NULL
description TEXT
image_url TEXT
cuisine_id INTEGER FK -> Cuisines
user_id INTEGER FK -> Users (nullable, ON DELETE SET NULL)
average_rating REAL default 0
total_ratings INTEGER default 0

RecipeIngredients (junction)

Column Type Notes
recipe_id INTEGER PK, FK -> Recipes (CASCADE)
ingredient_id INTEGER PK, FK -> Ingredients
quantity REAL

RecipeInstructions

Column Type Notes
instruction_id INTEGER PRIMARY KEY
recipe_id INTEGER FK -> Recipes (CASCADE)
step_number INTEGER
description TEXT
ingredient_id INTEGER FK -> Ingredients (nullable)

IngredientAllergies (junction)

Column Type Notes
ingredient_id INTEGER PK, FK -> Ingredients (CASCADE)
allergy_id INTEGER PK, FK -> AllergiesInformation (CASCADE)

Allergens are linked to ingredients, not recipes. A recipe's allergens are derived from its ingredients.

RecipeDietary (junction)

Column Type Notes
recipe_id INTEGER PK, FK -> Recipes (CASCADE)
diet_id INTEGER PK, FK -> DietaryInformation (CASCADE)

A recipe can have multiple dietary classifications (e.g. "Vegetarien" + "Sans gluten").

RecipeGoals (junction)

Column Type Notes
recipe_id INTEGER PK, FK -> Recipes (CASCADE)
goal_id INTEGER PK, FK -> Goals (CASCADE)

A recipe can serve multiple goals (e.g. "Riche en proteines" + "Rapide et facile").

UserFavorites (junction)

Column Type Notes
user_id INTEGER PK, FK -> Users (CASCADE)
recipe_id INTEGER PK, FK -> Recipes (CASCADE)
added_at DATETIME default CURRENT_TIMESTAMP

RecipeRatings

Column Type Notes
rating_id INTEGER PRIMARY KEY, AUTOINCREMENT
user_id INTEGER NOT NULL, FK -> Users (CASCADE)
recipe_id INTEGER NOT NULL, FK -> Recipes (CASCADE)
rating INTEGER 1-5, NOT NULL
review_text TEXT nullable
created_at DATETIME default CURRENT_TIMESTAMP
updated_at DATETIME default CURRENT_TIMESTAMP

UNIQUE constraint on (user_id, recipe_id) — one rating per user per recipe.


Authentication

The API uses session-based authentication (cookies).

How it works

  1. Call POST /api/users/login with email + password.
  2. The server creates a session and sends back a Set-Cookie header.
  3. Include that cookie in all subsequent requests (browsers do this automatically; in Postman, enable "Send cookies").
  4. Call POST /api/users/logout to destroy the session.

Access levels

Level Description
Public No login required. Anyone can read recipes, cuisines, ingredients.
Authenticated Must be logged in. Required to create recipes, rate, favorite, etc.
Owner Must be logged in AND own the recipe. Required to edit/delete your own recipes. Admins bypass this check.
Admin Must be logged in AND have is_admin = 1. Required for cuisine CRUD and ingredient allergen management.

Connecting from a Frontend

CORS

The API accepts requests from any origin (Access-Control-Allow-Origin: *). This means your frontend can run on a different port (e.g. localhost:5173 with Vite) and still call the API.

However, the wildcard * does not allow sending cookies cross-origin. Since authentication relies on session cookies, you have two options:

Option A: Proxy (recommended)

Configure your frontend dev server to proxy API requests so both frontend and API share the same origin. No cookie issues.

Vite (vite.config.js):

export default defineConfig({
  server: {
    proxy: {
      '/api': 'http://localhost:3050'
    }
  }
})

Then call /api/recipes from your frontend code (no http://localhost:3050 prefix needed).

React (Create React App) (package.json):

{
  "proxy": "http://localhost:3050"
}

Option B: Update CORS for credentials

In app.js, replace the CORS middleware to allow your specific frontend origin with credentials:

app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', 'http://localhost:5173'); // your frontend URL
    res.header('Access-Control-Allow-Credentials', 'true');
    res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    if (req.method === 'OPTIONS') return res.sendStatus(200);
    next();
});

Then in your frontend fetch calls, add credentials: 'include':

// Login
const res = await fetch('http://localhost:3050/api/users/login', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  credentials: 'include',
  body: JSON.stringify({ email: '[email protected]', password: 'password123' })
});

// Authenticated request (cookie is sent automatically)
const recipes = await fetch('http://localhost:3050/api/recipes/my-recipes', {
  credentials: 'include'
});

Typical frontend workflow

  1. Public pages (no login needed): call GET /api/recipes, GET /api/cuisines, etc.
  2. Register: POST /api/users/register
  3. Login: POST /api/users/login — a session cookie is set
  4. Authenticated actions: create recipes, rate, favorite — the cookie is sent with each request
  5. Logout: POST /api/users/logout

API Reference

All endpoints return JSON in this format:

{
  "success": true,
  "data": { ... }
}

On error:

{
  "success": false,
  "message": "Error description"
}

Recipes

GET /api/recipes

Get all recipes with cuisine name, dietary categories, and goals.

Access: Public

Response:

{
  "success": true,
  "count": 4,
  "data": [
    {
      "recipe_id": 1,
      "title": "Poulet Alfredo",
      "description": "Une delicieuse recette de pates au poulet",
      "image_url": "poulet_alfredo.jpg",
      "average_rating": 0,
      "total_ratings": 0,
      "cuisine_name": "Italienne",
      "goals": ["Riche en proteines", "Adapte aux familles"],
      "dietary": ["Sans produits laitiers"]
    }
  ]
}

GET /api/recipes/:id

Get a single recipe with all details: ingredients, instructions, dietary, goals, and allergens.

Access: Public

Response:

{
  "success": true,
  "data": {
    "recipe_id": 1,
    "title": "Poulet Alfredo",
    "description": "Une delicieuse recette de pates au poulet",
    "image_url": "poulet_alfredo.jpg",
    "cuisine_id": 2,
    "user_id": null,
    "average_rating": 0,
    "total_ratings": 0,
    "cuisine_name": "Italienne",
    "ingredients": [
      { "ingredient_id": 1, "name": "Poulet", "unit": "grammes", "quantity": 200 },
      { "ingredient_id": 2, "name": "Pates", "unit": "grammes", "quantity": 300 }
    ],
    "instructions": [
      { "instruction_id": 1, "step_number": 1, "description": "Faites cuire les pates..." },
      { "instruction_id": 2, "step_number": 2, "description": "Faites cuire le poulet..." }
    ],
    "dietary": [
      { "diet_id": 1, "name": "Sans produits laitiers" }
    ],
    "goals": [
      { "goal_id": 2, "name": "Riche en proteines" },
      { "goal_id": 6, "name": "Adapte aux familles" }
    ],
    "allergens": [
      { "allergy_id": 1, "name": "Gluten" },
      { "allergy_id": 7, "name": "Ble" }
    ]
  }
}

Note: allergens are derived from the recipe's ingredients (through IngredientAllergies).


GET /api/recipes/cuisine/:cuisineId

Get recipes filtered by cuisine.

Access: Public


GET /api/recipes/goal/:goalId

Get recipes that match a specific goal (through junction table).

Access: Public


GET /api/recipes/no-allergens/:allergyId

Get recipes that do NOT contain the specified allergen in any of their ingredients.

Access: Public

Example: GET /api/recipes/no-allergens/1 returns recipes with no gluten-containing ingredients.


GET /api/recipes/my-recipes

Get recipes created by the currently logged-in user.

Access: Authenticated


POST /api/recipes

Create a new recipe.

Access: Authenticated

Body:

{
  "title": "My New Recipe",
  "description": "A great recipe",
  "image_url": "image.jpg",
  "cuisine_id": 2
}

Required fields: title, description, cuisine_id.


PUT /api/recipes/:id/title

Update recipe title.

Access: Owner

Body:

{
  "title": "Updated Title"
}

POST /api/recipes/:id/ingredients

Add an ingredient to a recipe.

Access: Owner

Body:

{
  "ingredient_id": 1,
  "quantity": 200
}

DELETE /api/recipes/:recipeId/ingredients/:ingredientId

Remove an ingredient from a recipe.

Access: Owner


POST /api/recipes/:id/instructions

Add an instruction step to a recipe.

Access: Owner

Body:

{
  "step_number": 4,
  "description": "Serve on a warm plate.",
  "ingredient_id": null
}

Required fields: step_number, description. ingredient_id is optional.


PUT /api/recipes/:id/instructions/:stepId

Update an instruction's description.

Access: Owner

Body:

{
  "description": "Updated instruction text"
}

DELETE /api/recipes/:id/instructions/:stepId

Delete an instruction from a recipe.

Access: Owner


POST /api/recipes/:id/dietary

Add a dietary classification to a recipe.

Access: Owner

Body:

{
  "diet_id": 5
}

DELETE /api/recipes/:id/dietary/:dietId

Remove a dietary classification from a recipe.

Access: Owner


POST /api/recipes/:id/goals

Add a goal to a recipe.

Access: Owner

Body:

{
  "goal_id": 2
}

DELETE /api/recipes/:id/goals/:goalId

Remove a goal from a recipe.

Access: Owner


GET /api/recipes/:id/ratings

Get all ratings for a recipe.

Access: Public

Response:

{
  "success": true,
  "data": {
    "average_rating": 4.5,
    "total_ratings": 2,
    "ratings": [
      {
        "rating": 5,
        "review_text": "Excellent!",
        "created_at": "2026-11-16T...",
        "username": "john_doe"
      }
    ]
  }
}

POST /api/recipes/:id/ratings

Rate a recipe (1-5 stars). One rating per user per recipe.

Access: Authenticated

Body:

{
  "rating": 5,
  "review": "Loved it!"
}

PUT /api/recipes/:id/ratings

Update your own rating.

Access: Authenticated

Body:

{
  "rating": 4,
  "review": "Still great but changed my mind slightly"
}

DELETE /api/recipes/:id/ratings

Delete your own rating.

Access: Authenticated


DELETE /api/recipes/:id

Delete a recipe and all its related data (ingredients, instructions, dietary, goals, ratings).

Access: Owner


Cuisines

GET /api/cuisines

Get all cuisines, sorted alphabetically.

Access: Public

Response:

{
  "success": true,
  "count": 11,
  "data": [
    { "cuisine_id": 8, "name": "Americaine" },
    { "cuisine_id": 1, "name": "Asiatique" },
    ...
    { "cuisine_id": 11, "name": "Internationale" }
  ]
}

GET /api/cuisines/:id

Get a cuisine with its associated recipes.

Access: Public


POST /api/cuisines

Create a new cuisine.

Access: Admin

Body:

{
  "name": "Coréenne"
}

PUT /api/cuisines/:id

Update a cuisine's name.

Access: Admin

Body:

{
  "name": "Updated Name"
}

DELETE /api/cuisines/:id

Delete a cuisine. All recipes using this cuisine are reassigned to "Internationale" before deletion. The "Internationale" cuisine itself cannot be deleted.

Access: Admin


Ingredients

GET /api/ingredients

Get all ingredients, sorted alphabetically.

Access: Public


GET /api/ingredients/:id

Get an ingredient with its associated recipes and allergens.

Access: Public

Response:

{
  "success": true,
  "data": {
    "ingredient_id": 2,
    "name": "Pates",
    "unit": "grammes",
    "recipes": [
      { "recipe_id": 1, "title": "Poulet Alfredo", "quantity": 300 }
    ],
    "recipe_count": 1,
    "allergies": [
      { "allergy_id": 1, "name": "Gluten" },
      { "allergy_id": 7, "name": "Ble" }
    ]
  }
}

GET /api/ingredients/:id/allergies

Get allergens for a specific ingredient.

Access: Public


POST /api/ingredients

Create a new ingredient.

Access: Authenticated

Body:

{
  "name": "Riz",
  "unit": "grammes"
}

PUT /api/ingredients/:id

Update an ingredient.

Access: Authenticated

Body:

{
  "name": "Riz basmati",
  "unit": "grammes"
}

DELETE /api/ingredients/:id

Delete an ingredient. Fails if the ingredient is used by any recipe.

Access: Authenticated


POST /api/ingredients/:id/allergies

Add an allergen to an ingredient.

Access: Admin

Body:

{
  "allergy_id": 1
}

DELETE /api/ingredients/:id/allergies/:allergyId

Remove an allergen from an ingredient.

Access: Admin


Users

POST /api/users/register

Register a new user.

Access: Public

Body:

{
  "username": "my_username",
  "email": "[email protected]",
  "password": "mypassword123",
  "first_name": "John",
  "last_name": "Doe"
}

Required fields: username, email, password.


POST /api/users/login

Login and create a session.

Access: Public

Body:

{
  "email": "[email protected]",
  "password": "mypassword123"
}

After a successful login, a session cookie is set. Include it in future requests.


POST /api/users/logout

Destroy the session and log out.

Access: Authenticated


GET /api/users/profile

Get the current user's profile.

Access: Authenticated


PUT /api/users/profile

Update the current user's profile.

Access: Authenticated

Body:

{
  "username": "new_username",
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Doe"
}

PUT /api/users/password

Change password.

Access: Authenticated

Body:

{
  "currentPassword": "oldpassword",
  "newPassword": "newpassword123"
}

DELETE /api/users/profile

Delete the current user's account.

Access: Authenticated


GET /api/users/favorites

Get the current user's favorite recipes.

Access: Authenticated


POST /api/users/favorites/:recipeId

Add a recipe to favorites.

Access: Authenticated


DELETE /api/users/favorites/:recipeId

Remove a recipe from favorites.

Access: Authenticated


GET /api/users/ratings

Get all ratings made by the current user.

Access: Authenticated


Reference ID Tables

Use these IDs when building dropdowns, filters, or forms in your frontend. These are the values pre-loaded by setup-database.js.

Cuisines

ID Name
1 Asiatique
2 Italienne
3 Chinoise
4 Francaise
5 Mexicaine
6 Indienne
7 Mediterraneenne
8 Americaine
9 Thailandaise
10 Japonaise
11 Internationale

Goals

ID Name
1 Perte de poids
2 Riche en proteines
3 Riche en nutriments
4 Faible en calories
5 Rapide et facile
6 Adapte aux familles
7 Economique
8 Occasions speciales

Dietary Categories

ID Name
1 Sans produits laitiers
2 Sans Oeufs
3 Sans sucre
4 Sans gluten
5 Vegetarien
6 Vegetalien
7 Paleo
8 Cetogene
9 Faible en glucides
10 Faible en matieres grasses

Allergens

ID Name
1 Gluten
2 Produits laitiers
3 Noix
4 Fruits de mer
5 Soja
6 Oeufs
7 Ble

Ingredients

ID Name Unit
1 Poulet grammes
2 Pates grammes
3 Tomates unites
4 Huile d'olive cuilleres a soupe
5 Laitue feuilles
6 Parmesan grammes
7 Croutons unites
8 Vinaigrette cesar cuilleres a soupe
9 Ail gousses
10 Oignons unites
11 Basilic feuilles
12 Mozzarella grammes

Testing with Postman

Configuration

  1. Ouvrir Postman et creer une nouvelle collection
  2. Base URL : toutes les requetes utilisent http://localhost:3050
  3. Cookies : Postman gere automatiquement les cookies de session. Apres un login reussi, le cookie est envoye avec toutes les requetes suivantes
  4. Verifier que le serveur tourne : npm run dev

Ordre de test recommande

1. Routes publiques (sans login)

Methode URL Description
GET http://localhost:3050/api/recipes Toutes les recettes
GET http://localhost:3050/api/recipes/1 Detail d'une recette
GET http://localhost:3050/api/recipes/cuisine/2 Recettes italiennes
GET http://localhost:3050/api/recipes/goal/2 Recettes riches en proteines
GET http://localhost:3050/api/recipes/no-allergens/1 Recettes sans gluten
GET http://localhost:3050/api/cuisines Toutes les cuisines
GET http://localhost:3050/api/ingredients Tous les ingredients
GET http://localhost:3050/api/ingredients/2 Detail d'un ingredient (avec allergenes)
GET http://localhost:3050/api/ingredients/2/allergies Allergenes d'un ingredient
GET http://localhost:3050/api/recipes/1/ratings Avis sur une recette

2. Inscription et connexion

Inscription — POST http://localhost:3050/api/users/register

Body (raw JSON) :

{
  "username": "testuser",
  "email": "[email protected]",
  "password": "password123",
  "first_name": "Test",
  "last_name": "User"
}

Connexion — POST http://localhost:3050/api/users/login

Body (raw JSON) :

{
  "email": "[email protected]",
  "password": "password123"
}

Apres le login, Postman stocke automatiquement le cookie de session. Toutes les requetes suivantes sont authentifiees.

3. Routes authentifiees (apres login)

Creer une recette — POST http://localhost:3050/api/recipes

{
  "title": "Ma nouvelle recette",
  "description": "Une recette delicieuse",
  "image_url": "ma_recette.jpg",
  "cuisine_id": 2
}

Ajouter un ingredient a la recette — POST http://localhost:3050/api/recipes/5/ingredients

{
  "ingredient_id": 1,
  "quantity": 200
}

Ajouter une etape — POST http://localhost:3050/api/recipes/5/instructions

{
  "step_number": 1,
  "description": "Faire chauffer l'huile dans une poele.",
  "ingredient_id": 4
}

Ajouter une categorie dietetique — POST http://localhost:3050/api/recipes/5/dietary

{
  "diet_id": 5
}

Ajouter un objectif — POST http://localhost:3050/api/recipes/5/goals

{
  "goal_id": 2
}

Noter une recette — POST http://localhost:3050/api/recipes/1/ratings

{
  "rating": 5,
  "review": "Excellent !"
}

Ajouter aux favoris — POST http://localhost:3050/api/users/favorites/1

(pas de body necessaire)

Voir son profil — GET http://localhost:3050/api/users/profile

Voir ses recettes — GET http://localhost:3050/api/recipes/my-recipes

Voir ses favoris — GET http://localhost:3050/api/users/favorites

4. Suppression et modification

Methode URL Body
PUT /api/recipes/5/title {"title": "Titre modifie"}
PUT /api/recipes/5/instructions/1 {"description": "Etape modifiee"}
DELETE /api/recipes/5/goals/2 —
DELETE /api/recipes/5/dietary/5 —
DELETE /api/recipes/5/instructions/1 —
DELETE /api/recipes/5/ingredients/1 —
DELETE /api/recipes/1/ratings —
DELETE /api/users/favorites/1 —
DELETE /api/recipes/5 —

5. Deconnexion

Logout — POST http://localhost:3050/api/users/logout

Apres deconnexion, les requetes authentifiees retournent 401 Access denied.

Erreurs courantes

Erreur Cause Solution
401 Access denied Pas connecte ou session expiree Refaire un POST /api/users/login
403 Forbidden Vous n'etes pas le proprietaire de la recette Modifier uniquement vos propres recettes
404 Not found L'ID n'existe pas Verifier l'ID dans l'URL
409 Conflict Doublon (ex : meme allergene deja assigne) L'association existe deja
500 Database error Erreur serveur Verifier que le serveur tourne et que la DB existe

Sample Data

The database comes pre-loaded with sample data when you run node database/setup-database.js.

Cuisines (11)

Asiatique, Italienne, Chinoise, Francaise, Mexicaine, Indienne, Mediterraneenne, Americaine, Thailandaise, Japonaise, Internationale

Goals (8)

Perte de poids, Riche en proteines, Riche en nutriments, Faible en calories, Rapide et facile, Adapte aux familles, Economique, Occasions speciales

Dietary Categories (10)

Sans produits laitiers, Sans Oeufs, Sans sucre, Sans gluten, Vegetarien, Vegetalien, Paleo, Cetogene, Faible en glucides, Faible en matieres grasses

Allergens (7)

ID Name
1 Gluten
2 Produits laitiers
3 Noix
4 Fruits de mer
5 Soja
6 Oeufs
7 Ble

Recipes (4)

ID Title Cuisine Goals Dietary Allergens (via ingredients)
1 Poulet Alfredo Italienne Riche en proteines, Adapte aux familles Sans produits laitiers Gluten, Ble
2 Salade Cesar Japonaise Perte de poids, Faible en calories Faible en matieres grasses Produits laitiers, Gluten, Ble, Oeufs
3 Pasta Vegetarienne Italienne Riche en nutriments, Rapide et facile Vegetarien Gluten, Ble, Produits laitiers
4 Stir-Fry Asiatique Asiatique Riche en proteines, Rapide et facile Sans produits laitiers, Faible en glucides (none)

Sample Users (3)

Username Email Password
john_doe [email protected] (hashed, not usable for login — register your own)
jane_smith [email protected] (hashed)
chef_mike [email protected] (hashed)

The sample users have pre-generated bcrypt hashes that don't correspond to a known password. Register a new user through the API to test authenticated endpoints.


Resetting the Database

If you need to start fresh:

node database/setup-database.js

This deletes the existing recettes.db and recreates it with all tables and sample data.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages