{"id":22314549,"url":"https://github.com/leonardomenezes7/daily-diet-api","last_synced_at":"2026-05-03T19:33:32.812Z","repository":{"id":262924013,"uuid":"888786023","full_name":"leonardomenezes7/daily-diet-api","owner":"leonardomenezes7","description":"This is an API project for meal management, developed in the Node.js course by Rocketseat. I used TypeScript with Fastify, Knex, and SQLite. The API allows users to create accounts, log meals with detailed information, and access dietary habit metrics, including total meals and sequences within the diet.","archived":false,"fork":false,"pushed_at":"2024-11-15T04:53:38.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T02:46:24.550Z","etag":null,"topics":["api","knex","nodejs","sql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonardomenezes7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T02:12:17.000Z","updated_at":"2024-11-15T04:53:42.000Z","dependencies_parsed_at":"2024-11-15T03:27:38.875Z","dependency_job_id":"e848df86-b7fb-47e3-889d-ea7fc9894c9f","html_url":"https://github.com/leonardomenezes7/daily-diet-api","commit_stats":null,"previous_names":["leonardomenezes7/daily-diet-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leonardomenezes7/daily-diet-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardomenezes7%2Fdaily-diet-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardomenezes7%2Fdaily-diet-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardomenezes7%2Fdaily-diet-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardomenezes7%2Fdaily-diet-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonardomenezes7","download_url":"https://codeload.github.com/leonardomenezes7/daily-diet-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardomenezes7%2Fdaily-diet-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","knex","nodejs","sql","typescript"],"created_at":"2024-12-03T22:10:31.984Z","updated_at":"2026-05-03T19:33:32.778Z","avatar_url":"https://github.com/leonardomenezes7.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍴 Daily Diet API \nI developed an API project for meal management as part of Rocketseat’s Node.js course, focusing on technical implementation with TypeScript, Fastify, Knex, and SQLite. The API provides routes for user account creation, meal logging, and retrieval of detailed dietary metrics. Each route is designed to ensure that users can register meals with attributes like name, description, date, time, and dietary compliance. Additionally, it includes routes for editing, deleting, and viewing individual meals, as well as a metrics route to provide insights such as total meals, meals within or outside the diet, and the longest sequence of on-diet meals.\n\n## 📂 Project\n\u003cimg width=\"100%\" alt=\"Captura de Tela 2024-11-14 às 22 19 33\" src=\"https://github.com/user-attachments/assets/7c825d7b-356b-48f0-b6bf-b6e10b5f9f06\"\u003e\n\n### 🟢 Status: Development completed\n\n## ⚙️ Features\n- User Creation: Allows users to create an account to manage their meals.\n-\tUser Identification Between Requests: Implements a way to identify the user across requests, maintaining an active session.\n-\tMeal Logging: Enables users to log a meal with the following details: name, description, date and time, indicator of whether the meal is within or outside the diet.\n- Associating Meals with Users: All logged meals are linked to the user who created them.\n- Meal Editing: Allows users to edit all information of an existing meal (name, description, date and time, and diet indicator).\n- Meal Deletion: Enables users to delete a specific meal.\n- List All User Meals: Allows users to view a list of all meals they have logged.\n- View a Single Meal: Provides access to the details of a specific meal.\n- User Metrics Retrieval: Allows users to access metrics on their dietary habits, including: Total number of meals logged, total number of meals within the diet, total number of meals outside the diet, longest sequence of consecutive meals within the diet.\n- Access Restriction: Users can only view, edit, and delete meals that they have logged themselves, ensuring data privacy and security.\n\n## 🛠️ Technologies Used\n![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\n![SQLite](https://img.shields.io/badge/SQLite-316192?style=for-the-badge\u0026logo=sqlite\u0026logoColor=white)\n![Node.js](https://img.shields.io/badge/Node%20js-339933?style=for-the-badge\u0026logo=nodedotjs\u0026logoColor=white)\n![fastify](https://img.shields.io/badge/fastify-202020?style=for-the-badge\u0026logo=fastify\u0026logoColor=white)\n![Vitest](https://img.shields.io/badge/Vitest-202020?style=for-the-badge\u0026logo=vitest\u0026logoColor=white)\n\n## 💾 Database Structure\n\u003cimg width=\"100%\" alt=\"Captura de Tela 2024-11-14 às 22 41 24\" src=\"https://github.com/user-attachments/assets/59387a2f-0c1c-4dcf-abc8-741308f6ae61\"\u003e\n\n## 🎛️ Bussiness Rules\n\nusers:\n- `id` Unique identifier for each user\n- `session_id` Cookie identifier of each user between requests\n- `name` User name\n- `email` User email\n- `created_at` Timestamp when user was created\n- `updated_at` Timestamp when user was updated\n\nmeals:\n\n- `id` Unique identifier for each meal\n- `user_id` Foreign key that links the corresponding user to the meal\n- `name` Meal name\n- `description` Short description of the meal\n- `date` Meal date\n- `is_on_diet` Boolean that checks whether the meal is in the diet or not\n- `created_at` Timestamp when meal was created\n- `updated_at` Timestamp when meal was updated\n\n## ↔️ Routes\n- `POST /users` Creates a user in the database by sending the `name` and `email` fields in the request body and creates a `session_id` cookie in the application headers, the `created_at`, `session_id` and `updated_at` fields are filled automatically.\n- `POST /meals` Creates a meal in the database by checking if there is a `session_id` cookie in the request headers and sending the `name`, `description`, `date`, `is_on_diet` fields through the request body, the `user_id`, `created_at` and `updated_at` fields are automatically filled in.\n- `GET /meals`  Lists all meals by the user’s `session_id as request cookies.\n- `GET /meals/:mealId` Lists a specific meal by the user’s `session_id` from request cookies and the meal id from request params.\n- `PUT /meals/:mealId` Updates a user's meal searched for by the `session_id` cookie and changes the desired data by sending `name`, `description`, `date` and `is_on_diet` via the request body, the `updated_at` field is automatically filled in.\n- `DELETE /meals/:mealId` Deletes a meal from the database by sending the `id` via request params.\n- `GET /meals/metrics` List of user metrics using the `session_id` cookie, informing the total number of meals, number of meals inside and outside the diet and the longest sequence of meals within the diet.\n\n## 🚀 How To Run\n```bash\n# Clone the project to the desired location on your computer.\n$ git clone https://github.com/leonardomenezes7/daily-diet-api\n\n# Navigate to the directory\n$ cd daily-diet-api\n\n# Install the dependencies\n$ npm install\n\n# Run Database migrations\n$ npm run knex -- migrate:latest\n\n# Create a .env file and enter the necessary variables based on .env.example file\n\n# Start the server\n$ npm run dev\n```\n\n## 📎 About\nI developed this project as part of Rocketseat’s Node.js course, where I learned a lot about REST API development. This experience helped me gain a deeper understanding of building robust APIs, handling requests, managing databases, and implementing best practices in backend development.\n\n### 👤 Developed by [Leonardo Menezes](https://www.linkedin.com/in/leonardo-menezes-04629a292/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardomenezes7%2Fdaily-diet-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonardomenezes7%2Fdaily-diet-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardomenezes7%2Fdaily-diet-api/lists"}