I developed this project as a challenge of my latest studies on Node lessons at Rocketseat.
This project was developed to practice the development of a API REST in Node.js with Fastify. It was applied E2E tests on routes using Vitest along with supertest to make requests. Knex was used as query builder alongside with SQLite database on development enviroment and PostgreSQL on production.
To get started with the api flow, you'll have to create a new user before managing with the meals, this app hasn't a authentication system, so it will be used a simple cookie session to identify the active user (created during user creation).
Setup enviroment variables and run:
npm i
npm run knex -- migrate:latest
npm run dev
npm test
Method | Route | Params/Body |
---|---|---|
POST |
/users/ | name, email |
GET |
/users/ | - |
Method | Route | Params/Body |
---|---|---|
GET |
/meals/ | - |
GET |
/meals/:id | - |
POST |
/meals/ | name, description, is_on_diet, eated_at |
PUT |
/meals/:id | name, description, is_on_diet, eated_at |
DELETE |
/meals/:id | - |
GET |
/meals/summary | - |
- It should be possible to create a user
- It should be possible to identify the user between requests
- It should be possible to register a meal with: user id, name, description, date and time, it's in diet or not
- It should be possible to edit a meal with all data listed above.
- It should be possible to delete a meal
- It should be possible to list all user meals
- It should be possible to show a specific meal
- It should be possible to retrieve summary metrics containing:
- Number of all meals registered
- Number of all meals respecting the diet
- Number of all meals out of diet
- Better sequence of meals on diet
- The user should be able to show, edit and delete meals created by theirs