Skip to content

ryanf10/nestjs-auth-mongodb

Repository files navigation

Nest Logo

Description

Nest framework TypeScript starter repository. This repository consists of:

  • 🔼 NestJS 10
  • ✨ TypeScript
  • 📏 ESLint — Find and fix problems in your code
  • 💖 Prettier — Format your code consistently
  • 🐶 Husky — Run scripts before they are committed
  • 🔑 RBAC — Authentication and Role Authorization starter kit
  • 📃 Pagination — Built-in pagination builder
  • 📡 Socket.io — Websocket with authentication and realtime notifications
  • ☁️ Chat — Implement a robust real-time chat feature using Socket.io, allowing seamless communication between users.
  • 🔍 Cache — Redis
  • 📄 Api Documentation — Swagger
  • ⛵ Docker — Alpine, Redis, MongoDB
  • 📕 Logger — Winston
  • 🔚 End to End Testing — Perform end to end testing with different environment

Installation

yarn install

Installation

yarn husky install
chmod ug+x .husky/*

Running the app

development

yarn run start

watch mode

yarn run start:dev

production mode

yarn run start:prod

Running the app with Docker

Local Development

docker build --no-cache -f Dockerfile.local .
docker-compose -f docker-compose.local.yml up --build -d

Production

docker-compose build --no-cache
docker-compose up --build -d

Accessing container shell

docker exec -it myapp sh
docker exec -it redis sh
redis-cli
docker exec -it mongodb sh
mongosh

Seed role to MongoDB

yarn nestjs-command seed:role

File Storage

  • Local (Set Storage to 'local' in .env)
STORAGE=local
S3_ENDPOINT_URL=https://sgp1.digitaloceanspaces.com/
S3_DOWNLOAD_URL=https://<your-bucket>.sgp1.digitaloceanspaces.com/
S3_BUCKET=<your-bucket>
S3_ACCESS_KEY_ID=<your-access-key>
S3_SECRET_KEY=<your-secret-key>
  • S3 (Set Storage to 's3' in .env)
STORAGE=s3

API Documentation

http://localhost:3000/swagger

Simple Live Chat with WebSocket Demo

http://localhost:3000

Test

unit tests

yarn run test

e2e tests

yarn run test:e2e

test coverage

yarn run test:cov

Frontend Support

You can use this Project as your frontend. It created with Next.js, Tailwind CSS, and Typescript.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

Nest is MIT licensed.