Skip to content

gcrozariol/daily-diet-api

Repository files navigation

Rocketseat's Ignite Node.js Module // Project #02

🚀 Daily Diet API

This challenge is about creating a RESTful API to control a daily diet. Here are the application's use cases:

[X] Create a user

[X] Idenfify the user when making a request

[X] Create a meal related to a user with the following informations:

   [X] Name

   [X] Description

   [X] Date and time

   [X] Let the user select if this meal is on a diet or not

[X] Update one or more fields of a meal

[X] Delete a meal

[X] List all meals of a user

[X] List a single meal

[X] Get metrics of a user by returning the following:

   [X] Amount of meals

   [X] Amount of meals on a diet

   [X] Amount of meals off a diet

   [X] Best day on a diet

[X] The user can only view, edit and delete meals which he created.

🎯 Running the App

Run the following command to start the project:

npm run dev

Now, with the server running locally using the port 3333, we are ready to make some requests.

🛜 Making Requests

  • Create a user
    • Method    →  POST
    • Endpoint  →  http://localhost:3333/users
    • Body request must contain both name and email parameters. The avatar parameter is optional.

  • Create a meal
    • Method    →  POST
    • Endpoint  →  http://localhost:3333/meals
    • Body request must contain name, description, is_diet, and date parameters.




  • Update a meal
    • Method    →  PUT
    • Endpoint  →  http://localhost:3333/meals/:id
    • Body request must contain at least one of the following parameters name, description, is_diet, and date.


🧪 Running the App's Tests

Run the following command to run the tests:

npm test

About

This is a RESTful API to control daily diets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published