This is a NestJS project for a simple bookmark management application. It allows users to sign up, sign in, create, edit, and delete bookmarks. The project uses Prisma as the ORM for database operations and JWT for authentication. Below is how to get started and an overview of the project's file structure and functionalities.
- Clone the repository:
git clone <repository_url>
- Install dependencies:
cd <project_directory>
yarn install
- Configure environment variables:
- Create a .env file for development and a .env.test file for testing.
- Define the DATABASE_URL and JWT_SECRET variables in both files.
- Start the development database (PostgreSQL) using Docker Compose:
- yarn db:
- This file defines the database schema using Prisma DSL.
- It specifies the data models (User and Bookmark) and their relationships.
- Prisma is a powerful tool for database management and is used to interact with the PostgreSQL database.
- This file contains a custom decorator @GetUser, which retrieves user information from the request object.
- It is used to access user details in the controllers.
- Decorator Export (../src/auth/decorator/index.ts)
- This file exports the @GetUser decorator to make it accessible in other parts of the application.
- This file defines the data transfer object (DTO) for user authentication.
- It specifies validation rules for email and password fields.
- This file exports the authentication DTO for use in other parts of the application.
- This file exports the JWT authentication guard for use in other parts of the application.
- This file contains a custom JWT authentication guard.
- It is used to protect routes that require authentication using JWT tokens.
- This file exports the JWT authentication strategy for use in other parts of the application.
- This file defines the JWT authentication strategy.
- It validates JWT tokens and retrieves user information from the database.
- This file defines the authentication controller, including signup and signin routes.
- This file defines the authentication module, including controller and provider registration.
- This file contains the business logic for user authentication, signup, and signin.
- It interacts with the Prisma service to perform database operations.
- This directory contains DTOs for creating and editing bookmarks.
- This file defines the bookmark controller, including routes for creating, editing, and deleting bookmarks.
- This file defines the bookmark module, including controller and service registration.
- This file contains the business logic for bookmark management, including CRUD operations.
- This file defines the Prisma module, which provides the Prisma client as a singleton service.
- This file contains the Prisma service, which initializes the Prisma client and provides methods for interacting with the database.
- It also includes a method to clean the database for testing purposes.
- This file defines the DTO for editing user profile information.
- This file exports the user DTO for use in other parts of the application.
- This file defines the user controller, including routes for retrieving user information and editing profiles.
- This file defines the user module, including controller and service registration.
- This file contains the business logic for editing user profiles.
- It interacts with the Prisma service to update user data.
- This file defines the main application module, including the registration of all modules used in the application.
- It also includes global validation pipe setup.
- This file serves as the entry point of the application.
- It creates the NestJS application, sets up global validation pipes, and starts the server.
- This file contains end-to-end tests using Jest and Pactum for the entire application.
- It tests routes related to authentication, user management, and bookmark management.
- This file specifies the configuration for Jest end-to-end testing.
- These files contain environment variables for configuring the database connection and JWT secret.
- .env is used for development, and .env.test is used for testing.
- This file contains ESLint configuration rules for the project.
- This file defines Docker Compose services for development and testing databases (PostgreSQL).
- This file contains project dependencies, scripts for building, running, and testing the application.
- This file specifies the configuration for the Nest CLI.
- This file extends the TypeScript configuration for building the application.
- This file contains TypeScript compiler options for the project.