The Bookstore API is a study project focused on Test-Driven Development (TDD). It provides HTTP endpoints for managing books, book rentals, and user information.
This project was developed as part of the final test of the TDD module provided by Ada tech in collaboration with iFood.
To install the project and its dependencies, follow these steps:
Before install the project, make sure you have the following tools installed:
Now, follow the steps below to use the project:
-
Clone the Repository:
git clone https://github.com/DavidWesley/ifood-bookstore-api-tdd bookstore-api cd bookstore-api
-
Navigate to the Project Directory:
cd your-project
-
Install Dependencies:
npm install
-
Run migrations:
cd src/db/ npx tsx migrate.ts
There are two ways to run the project, each serving a different purpose:
This mode is suitable for active development, providing features like hot-reloading and enhanced debugging tools.
-
Run in development mode:
npm run dev
-
Access the Application:
- Open your browser and go to http://localhost:3000.
- Build the project:
npm run build
- Start in build mode:
npm start
- Access the Application:
- Open your browser and go to http://localhost:3000.
This mode optimizes the project for production, maybe ensuring better performance.
To run tests for the project, use the following commands:
- Run Tests:
npm run test
- Generate Coverage Report:
npm run test:coverage
- Run Tests in Watch Mode:
These commands will execute the tests, generate a coverage report (optional), and run tests in watch mode for continuous testing.
npm run test:watch
The following scripts are available:
npm test
: Run tests.npm run test:watch
: Run tests in watch mode.npm run test:coverage
: Generate test coverage report.npm run lint
: Run linting checks.npm run format
: Format code.npm start
: Start the server in production mode.npm run dev
: Start the server in development mode.npm run build
: Build the project.
The tables below provide a summary of the main API routes. For additional details on each route, please refer to Routes.md.
Route | HTTP Method | Description |
---|---|---|
/v1/users |
GET | Retrieves a list of all users. |
/v1/users/:id |
GET | Retrieves detailed information about a specific user. |
/v1/users |
POST | Creates a new user based on the provided data. |
/v1/users/:id |
PUT | Updates information for a specific user. |
/v1/users/:id |
DELETE | Removes a specific user. |
Route | HTTP Method | Description |
---|---|---|
/v1/books |
GET | Retrieves a list of all books. |
/v1/books/:id |
GET | Retrieves detailed information about a specific book. |
/v1/books |
POST | Creates a new book based on the provided data. |
/v1/books/:id |
PUT | Updates information for a specific book. |
/v1/books/:id |
DELETE | Removes a specific book. |
Route | HTTP Method | Description |
---|---|---|
/v1/rental/books |
GET | Retrieves a list of all book rentals. |
/v1/rental/books/:id |
GET | Retrieves detailed information about a specific book rental. |
/v1/rental/books |
POST | Creates a new book rental based on the provided data. |
/v1/rental/books/:id |
PUT | Updates information for a specific book rental. |
/v1/rental/books/:id |
DELETE | Removes a specific book rental. |
Refer to Routes.md for detailed documentation on each route.
The most updated version of the image above can be found at Diagrama
I appreciate all the individuals who have contributed to this project! 🙌
- @DavidWesley David Wesley
- @lgsrocha Lucas Rocha
- @Alan-Vasconi Alan Vasconi
- @daniellabernardino Daniella Maria