Hello, this is web application built in nodeJS, typescript with database mysql, using PrismaORM, and containerized. This API project was created as one of the company's recruitment processes (LOGIQUE / KAZOKU).
Efendi Salim
-
Install Docker If you don't have Docker installed, you can download and install it from the official Docker website: Download Docker
-
Clone the Project Clone the repository to your local machine using the following command:
git clone <repository-url>
- Build and Start the Application
cd <project-directory>
docker compose up --build
- Usage: The entire project is implemented in TypeScript, including type definitions for data and API parameters.
- Files:
src/index.ts
- Main application entry point.src/controllers/Book.controller.ts
- Controller for book CRUD operations.src/routes/Book.routes.ts
- Routing for book-related API endpoints.src/utils/response.mapper.ts
- Utility for standardizing API responses.src/tests/book.test.ts
- Unit tests for book-related endpoints.
- Implemented: Comprehensive error handling for various cases:
- Data Not Found: Returns a 404 status with a message indicating that the resource was not found.
- Input Validation: Validates request data using
express-validator
and returns a 400 status with details on validation errors. - Server Errors: Catches and logs server errors, returning a 500 status with a generic error message.
- Testing Framework: Jest is used for unit testing.
- Tests Included:
- Create Book: Tests creation of a new book.
- Get Book by ID: Tests retrieval of a book by its ID.
- Get All Books with Pagination: Tests fetching of all books with pagination.
- Update Book: Tests updating an existing book.
- Delete Book: Tests deletion of a book.
- API Documentation: Detailed API documentation is available at Postman Documentation. This includes information on each endpoint, example requests, and responses.
- Rate Limiting: Implemented using
express-rate-limit
to prevent abuse of the API. - Input Sanitization: Ensured by using validation libraries like
express-validator
.
- Optimizations:
- Database Queries: Optimized queries to ensure efficient data retrieval and manipulation.
- Middleware Usage: Properly managed middleware to reduce performance overhead.
- Docker Configuration:
- Dockerfile: Defines the environment for the application.
- docker-compose.yml: Manages multi-container Docker applications, including the app and MySQL database.