This project is an API for managing meals and users. It supports CRUD operations, tracking meal streaks, and getting the total number of meals by user. The API uses Fastify for speed, TypeScript for type safety, SQLite for the database, and Knex for query building. Note that the project does not currently use authentication nor authorization. Please refer to the TODOS-example.md file as a guide to complete the project requirements.
- SQLite Database: Store data locally with SQLite.
- Knex Query Builder: Write clean SQL queries with Knex.
- Mock Data: Use Faker.js for generating mock data.
- End-to-End Testing: Test all endpoints with Vitest.
- Fastify Framework: Building efficient and fast APIs.
- TypeScript Integration: Enhancing code quality and maintainability.
- Database Management: Using SQLite and Knex for data persistence.
- Mock Data Generation: Utilizing Faker.js to create test data.
- End-to-End Testing: Implementing comprehensive tests with Vitest.
-
Clone the repository:
git clone https://github.com/rafaelrmb/dailydiet_api.git cd dailydiet_api
-
Install dependencies:
npm install
-
Run database migrations:
npx knex migrate:latest
-
Start the server:
npm run dev
-
GET - /meals
- List all meals.
-
POST - /meals
- Create a new meal.
-
GET - /meals/:id
- List a meal by
id
.
- List a meal by
-
DELETE - /meals/:id
- Delete a meal by
id
.
- Delete a meal by
-
PUT - /meals/:id
- Edit a meal by
id
.
- Edit a meal by
-
GET - /meals/streak
- Show user's meals streak.
-
GET - /meals/totals
- Show total number of meals by user.
- Show total number of meals on diet.
- Show total number of meals off diet.
-
GET - /users
- List all users.
-
GET - /users/:id
- List a user by
id
.
- List a user by
-
POST - /users
- Create a new user.