🍷 Alcool API Documentation

📢 Overview

This API allows users to manage a collection of alcoholic beverages. It provides authentication through JSON Web Tokens (JWT) and supports CRUD (Create, Read, Update, Delete) operations for alcohol data and user comments.

Base URL: https://alcool-api.pierrenogaro.com/

API Introduction

🔐 Authentication

To use the API, you need to register and then log in to receive a token for secure access to protected routes.

Register

POST /auth/register - Register a new user with a username and password.

Headers: Content-Type: application/json 
Body: { "username": "yourUsername", "password": "yourPassword" }

Login

POST /auth/login - Log in with your credentials to receive a token for authentication.

Headers: Content-Type: application/json 
Body: { "username": "yourUsername", "password": "yourPassword" }
Note: Use the returned token in the Authorization header for all protected routes.

🍸 Alcools Routes

The following endpoints allow you to manage the alcohol collection. All routes require authentication with a token.

Get All Alcools

GET /alcools/all - Retrieve a list of all alcoholic beverages.

Get a Specific Alcool

GET /alcools/:id - Retrieve details for a specific beverage by its ID.

Example Request:

GET /alcools/12345
Create a New Alcool

POST /alcools/create - Add a new alcoholic beverage to the collection.

Headers: Authorization: Bearer <token> 
Body: { "name": "AlcoolName", "degree": "45", "ingredients": ["sugar", "water"], "description": "A fine drink" }
Update an Alcool

PUT /alcools/update/:id - Update an alcoholic beverage's details by its ID.

Headers: Authorization: Bearer <token> 
Body: { "name": "UpdatedName", "degree": "50" }

🗨️ Comments Routes

Add a Comment

POST /comments/:alcoolId - Add a comment to an alcool.

Headers: Authorization: Bearer <token>
Body: { "content": "Great drink!" }
Update a Comment

PUT /comments/:id - Update a comment by its ID.

Headers: Authorization: Bearer <token>
Body: { "content": "Updated content." }
Delete a Comment

DELETE /comments/:id - Remove a comment by its ID.

Headers: Authorization: Bearer <token>

⚠️ Common Errors

  • 400 Bad Request: Invalid data or missing fields in the request body.
  • 401 Unauthorized: Missing or invalid token in the Authorization header.
  • 403 Forbidden: User does not have permission to access the resource.
  • 404 Not Found: Resource not found (e.g., alcool or comment not found).