This is a NestJS project that uses Prisma as the ORM for database interactions. The project includes authentication, user management, and bookmark management features.
- Authentication: Secure user authentication using JWT (JSON Web Tokens). This includes user registration, login, and token-based authentication to protect routes and resources.
- User Management: CRUD (Create, Read, Update, Delete) operations for managing user profiles. Users can update their personal information and manage their accounts.
- Bookmark Management: Functionality for users to create, read, update, and delete bookmarks. This feature allows users to save and manage their favorite links or resources.
- Signup: Users can register by providing an email and password. The password is hashed using Argon2 before being stored in the database.
- Signin: Users can log in by providing their email and password. A JWT token is generated and returned upon successful authentication.
- JWT Strategy: Protects routes by validating the JWT token provided in the Authorization header.
- Get Current User: Users can retrieve their profile information.
- Edit User: Users can update their email, first name, and last name.
- Create Bookmark: Users can create a new bookmark by providing a title, description, and link.
- Get Bookmarks: Users can retrieve a list of all their bookmarks.
- Get Bookmark by ID: Users can retrieve a specific bookmark by its ID.
- Edit Bookmark: Users can update the title, description, and link of a specific bookmark.
- Delete Bookmark: Users can delete a specific bookmark.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
yarn install
-
Set up the environment variables:
cp .env.example .env
-
Update the .env file with your database connection string and JWT secret.
-
Start the PostgreSQL database using Docker:
docker-compose up -d
-
Run the application:
yarn start:dev
The application will be running at http://localhost:3000.
The following environment variables are used in this project:
DATABASE_URL: The connection string for the PostgreSQL database.JWT_SECRET: The secret key for signing JWT tokens.
To run the database migrations, use the following commands:
-
Initialize Prisma:
npx prisma init
-
Run migrations:
npx prisma migrate dev
-
Deploy migrations:
npx prisma migrate deploy
-
Open Prisma Studio:
npx prisma studio
.env
.env.example
.env.test
.eslintrc.js
.gitignore
.prettierrc
docker-compose.yml
nest-cli.json
nest.txt
package.json
prisma/
migrations/
20241003133001_init/
20241004085606_update_models/
migration_lock.toml
schema.prisma
README.md
src/
app.module.ts
auth/
auth.controller.ts
auth.module.ts
auth.service.ts
decorator/
get-user.decorator.ts
dto/
auth.dto.ts
index.ts
guard/
jwt.guard.ts
strategy/
jwt.strategy.ts
bookmark/
bookmark.controller.ts
bookmark.module.ts
bookmark.service.ts
dto/
create-bookmark.dto.ts
edit-bookmark.dto.ts
index.ts
main.ts
prisma/
prisma.module.ts
prisma.service.ts
user/
dto/
edit-user.dto.ts
index.ts
user.controller.ts
user.module.ts
user.service.ts
test/
app.e2e-spec.ts
jest-e2e.json
tsconfig.build.json
tsconfig.json
To run the tests, use the following command:
yarn testTo run end-to-end tests:
yarn test:e2eContributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License.