GithubHelp home page GithubHelp logo

api_diet_control's Introduction

Diet control RESTful API

Technologies Used


Endpoints:

Users

Get All Users

  • Endpoint: GET /user/all
  • Description: Get a list of all users.
  • Authorization: Required (jwtValidationMiddleware)

Get User by ID

  • Endpoint: GET /user/:id
  • Description: Get user details by user ID.
  • Authorization: Required (jwtValidationMiddleware)

Create User

  • Endpoint: POST /user

  • Description: Create a new user.

  • Authorization: Not required.

  • Middleware: userMiddleware

  • Body example:

    {
      "name": "Nikolas Menezes",
      "password": "crazy_password123",
      "email": "[email protected]",
      "isPremium": true
    }

Update User

  • Endpoint: PATCH /user/:id

  • Description: Update user details by user ID.

  • Authorization: Required (jwtValidationMiddleware)

    {
      "name": "Nikolas Menezes",
      "password": "crazy_password123",
      "email": "[email protected]",
      "isPremium": true
    }

obs: you can send just one of this properties to update instead of all them.

Delete User

  • Endpoint: DELETE /user/:id
  • Description: Delete user by user ID.
  • Authorization: Required (jwtValidationMiddleware)

User Basic Information

Get User Basic Info

  • Endpoint: GET /user/info/:id
  • Description: Get basic information of a user by user ID.
  • Authorization: Required (jwtValidationMiddleware)

Store User Basic Info

  • Endpoint: POST /user/info/:id

  • Description: Store basic information for a user.

  • Authorization: Required (jwtValidationMiddleware)

  • Middleware: verifyUserBasicInfoFields

  • Body example:

    {
      "age": 30,
      "gender": "male",
      "height": 179,
      "weight": 85
    }

Update User Basic Info

  • Endpoint: PATCH /user/info/:id

  • Description: Update basic information for a user.

  • Authorization: Required (jwtValidationMiddleware)

  • Body example:

    {
      "age": 30,
      "gender": "male",
      "height": 179,
      "weight": 85
    }

obs: you can send just one of this properties to update instead of all them.

Authentication

User Login

  • Endpoint: POST /login

  • Description: Authenticate user and generate a JWT token.

  • Authorization: Not required.

  • Body example:

    {
      "email": "[email protected]",
      "password": "admin"
    }
  • Response Example:

    {
      "status": "success",
      "token": "your token comes here",
      "expiresIn": 1708128269245
    }

Food Generics

Get All Foods

  • Endpoint: GET /food/all
  • Description: Get a list of all food generics.
  • Authorization: Required (jwtValidationMiddleware)

Get Foods by Group

  • Endpoint: GET /food
  • Description: Get food generics by group.
  • Authorization: Required (jwtValidationMiddleware)
  • Middleware: validateSentGroup

Get Food by ID

  • Endpoint: GET /food/:id
  • Description: Get food details by ID.
  • Authorization: Required (jwtValidationMiddleware)
  • Middleware: validateSentGroup

Meals

Get User Meals

  • Endpoint: GET /meal/user
  • Description: Get all meals for a user.
  • Authorization: Required (jwtValidationMiddleware)

Get Meal by ID

  • Endpoint: GET /meal/:id
  • Description: Get meal details by ID.
  • Authorization: Required (jwtValidationMiddleware)

Create Meal

  • Endpoint: POST /meal

  • Description: Create a new meal.

  • Authorization: Required (jwtValidationMiddleware)

  • Middleware: verifyMealFields

  • Body example:

    {
      "user_id": 1,
      "foods_id": [1, 2],
      "name": "Dinner",
      "description": "Last meal of my day"
    }

Add Food to Meal

  • Endpoint: POST /meal/:id/food

  • Description: Add food to a meal.

  • Authorization: Required (jwtValidationMiddleware)

  • Body example:

    {
      "food_id": [7, 8, 9]
    }

Update Meal

  • Endpoint: PUT /meal/:id

  • Description: Update meal details.

  • Authorization: Required (jwtValidationMiddleware)

  • Middleware: verifyMealFields

  • Body example:

    {
      "name": "Lunch",
      "description": "The most important meal"
    }

Delete Meal by ID

  • Endpoint: DELETE /meal/:id
  • Description: Delete a meal by ID.
  • Authorization: Required (jwtValidationMiddleware)

Delete Food from Meal

  • Endpoint: DELETE /meal/:meal_id/food/:food_id
  • Description: Remove a specific food from a meal.
  • Authorization: Required (jwtValidationMiddleware)

api_diet_control's People

Contributors

nikolasmenezes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.