You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make and configure .env file in the root folder of the project:
# .envPORT=SERVICE_PORTDATABASE_URL=YOUR_POSTGRE_DATABASE_URI_CONNECTION# SecretKey must have at least 32 characters and contains uppercase characters, lowercase characters, and digits.JWT_ACCESS_TOKEN_SECRET_KEY=YOUR_SECRET_KEYJWT_REFRESH_TOKEN_SECRET_KEY=YOUR_SECRET_KEY# Tokens LifeTimeACCESS_TOKEN_LIFE_TIME=15#MinutesREFRESH_TOKEN_LIFE_TIME=7#Days# Rate LimitingRATE_LIMIT_TIME_TO_LIVE=10#SecondsRATE_LIMIT_MAX_NUMBER_REQUEST=2# CORSCORS_ORIGIN=http://test.com# ZoneTIME_ZONE=Asia/Tehran
Generate Prisma Client:
npx prisma generate
Push the Prisma schema state to the database:
npx prisma db push
Run the application:
npm run start
Routes
Route
Method
Description
/api/v1/auth/signup
Post
Signup
/api/v1/auth/signin
Post
Signin
/api/v1/auth/refresh
Post
Refresh
/api/v1/auth/logout
Post
Logout
Signup route parameters:
Parameter
Description
MinLength
MaxLength
username
username can only contain lowercase characters, digits, and underscores
5
10
password
password must contain at least one uppercase character, a lowercase character, a digit, and a special character
8
15
Signin route parameters:
Parameter
MinLength
MaxLength
username
4
20
password
4
20
Refresh route parameters:
Parameter
Value Format
Authorization
Bearer [RefreshToken]
Logout route parameters:
Parameter
Value Format
Authorization
Bearer [AccessToken]
Postman Collection
You can find it (*.postman_collection.json) in the root folder of the project.
About
Access Token + Refresh Token implementation in Node.js with Nestjs