Clone the repository
git clone https://github.com/minhtran241/bookmarks-api.git
Switch to the repo folder
cd bookmarks-api
Install dependencies
yarn install
Copy .env.example file to your .env file and set environment variables following instructions in this file (jwt, database, port information)
APP_PORT=
DATABASE_URL="postgresql://username:password@localhost:5434/dbname?schema=public"
JWT_EXPIRATION_IN_MINUTES=
JWT_SECRET=
The codebase contains Prisma database abstraction
Trigger docker container for PostgreSQL
yarn db:dev:up
Apply pending migrations to the database in production/staging
yarn prisma:dev:deploy
Browse your data
npx prisma studio
In case of you want to generate your own database from scratch, set up tables and generate the prisma client. For more information see the docs:
yarn start
- Start applicationyarn start:dev
- Start application in watch modeyarn test:e2e
- run E2E test runneryarn start:prod
- Build application
yarn db:dev:up
- Start PostgreSQL containeryarn db:dev:rm
- Remove PostgreSQL containeryarn db:dev:restart
- Restart PostgreSQL container and apply pending migrations to the database in production/stagingyarn db:test:up
- Start PostgreSQL container for testingyarn db:test:rm
- Remove PostgreSQL container for testingyarn db:test:restart
- Restart PostgreSQL container for testing and apply pending migrations to the database in production/staging
This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization
header with Token
scheme. The JWT authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT
src folder contains logic for all the modules, test folder contains logic for testing of the project
.
├── app.module.ts
├── auth
│ ├── auth.controller.ts
│ ├── auth.module.ts
│ ├── auth.service.ts
│ ├── decorator
│ │ ├── get-user.decorator.ts
│ │ └── index.ts
│ ├── dto
│ │ ├── auth
│ │ │ ├── login.dto.ts
│ │ │ └── signup.dto.ts
│ │ └── index.ts
│ ├── guard
│ │ ├── index.ts
│ │ └── jwt.guard.ts
│ └── strategy
│ ├── index.ts
│ └── 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
- File .env.test contains environment variables for testing
.
├── app.e2e-spec.ts
└── jest-e2e.json