Nest Bookmark API using NestJS
This project implements a RESTful Bookmark API using NestJS, following clean architecture principles. It provides endpoints to manage bookmarks for authenticated users, supporting operations like creating, retrieving, updating, and deleting bookmarks. The application is designed with separation of concerns in mind, ensuring maintainability, testability, and scalability.
- CRUD Operations: Create, Read, Update, and Delete bookmarks.
- Authentication: JWT-based authentication with guards to protect routes.
- Validation: Input validation using NestJS pipes and DTOs (Data Transfer Objects).
- Error Handling: Centralized error handling using NestJS filters.
- Database Integration: Persistence layer with TypeORM (or any other ORM of your choice).
- Scalable Architecture: Modular structure with independent layers for controllers, services, repositories, entities, and DTOs.
- Testing: Unit tests for services and controllers using Jest.
- Middleware: Custom middleware for logging, error handling, etc.
- Documentation: Clear and concise API documentation (Swagger/OpenAPI) for easy integration.
The project follows a clean architecture approach, organizing code into distinct layers:
src/
: Contains the source code for the application.controllers/
: HTTP request handlers.services/
: Business logic and data manipulation.entities/
: Database models and business objects.dto/
: Data Transfer Objects for input validation.middlewares/
: Middleware functions for cross-cutting concerns.auth/
: Authentication guards and decorators.exceptions/
: Custom exception filters for error handling.app.module.ts
: Main application module.main.ts
: Entry point for the application.
test/
: Unit tests for services and controllers using Jest.
- Node.js (version >= 12)
- npm or yarn
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/HarshMN2345/Bookmark-api/
$ npm install
# development
$ npm run start:dev
$ npm run db:dev:restart
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
API documentation is generated using Swagger. After starting the application, navigate to http://localhost:3333/api to explore the API using Swagger UI.