Skip to content

alanloffler/nest-auth-api

Repository files navigation

Nest Logo

Description

Nest auth API: Manage users login and registration.

Supports user roles and permissions. Authenticated routes can be protected by role-based access control and authorization. Local strategy and JWT strategy.

Project setup

$ npm install

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Enviroment file example (.env)

PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_postgres_username
DB_PASSWORD=your_postgres_password
DB_DATABASE=your_db_name
JWT_SECRET=token_secret
JWT_EXPIRES_IN=1m
JWT_REFRESH_SECRET=refreshtoken_secret
JWT_REFRESH_EXPIRES_IN=2m
BCRYPT_SALT_ROUNDS=12

Expires times are in minutes for testing purposes. Modify JWT_EXPIRES_IN and JWT_REFRESH_EXPIRES_IN to fit your needs.

Suggested values:

JWT_EXPIRES_IN=15m
JWT_REFRESH_EXPIRES_IN=5d

Role permission: use JwtAuthGuard and RolesGuard to access the endpoints (implemented in admin and roles controllers).

Stay in touch

License

nest-auth-api is MIT licensed.

About

A Nest.js auth API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published