Skip to content

trieuquang2106/NestJS-EJS-MVC-boilerplate

 
 

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Project badges

Quality Gate Status Maintainability Rating Security Rating Bugs Vulnerabilities Code Smells Technical Debt Lines of Code

SonarCloud

Description

Nest framework TypeScript starter repository.

Notice: This project is designed to work with both the Web MVC model and the REST architecture. With many features needed for a #RealWorld project

⚠️ DISCLAIMER: This project is still in development and not stable yet. It's not recommended to use it in production.

Get started

Notes:

  • Make sure you have Docker, Docker Compose and Node.js installed.
  • The run.sh script only works on Linux or MacOS. On Windows, you have to run it in MINGW64 environment (aka. Git bash) - a PowerShell script will be available soon. See the instructions.
  • You need to install PostgreSQL and Redis by yourself, if you don't want to use Docker.
https://github.com/tranphuquy19/NestJS-EJS-MVC-boilerplate # Clone this repository
cd NestJS-EJS-MVC-boilerplate # Go to the root of the repository

yarn # Install dependencies
bash ./run.sh up -d # will start all services. `-d` will run the services for development mode. 
yarn start:dev # Start the application in development mode

Start using Docker compose

bash ./run.sh build # Build the application image for production
bash ./run.sh up -p # Start PostgreSQL, Redis, PgAdmin and the application in production mode

bash ./run.sh down # Stop PostgreSQL, Redis, PgAdmin and the application
bash ./run.sh down:volumes # Destroy PostgreSQL, Redis, PgAdmin and the application

Contributing

I'm looking for help with fixing issues, adding new packages, docs and maintaining existing ones. It would be very helpful if you submit a pull request with bug fixes.

Features

Environments

  • production
  • development

View engine

API

GraphQL

Caching

  • API Response
  • Static files
  • Database queries
  • CDN

Authentication

  • Cookies/Session
  • Using Redis as Session Store
  • Basic auth
  • JWT auth
  • Refresh token
  • Web-socket auth
  • OAuth Google
  • OAuth Facebook
  • OAuth Github
  • Verify email
  • Time-based One-time password (TOTP)

Task scheduler

  • Timeout
  • Interval
  • Cron job

HTTP client

  • RESTful client
  • GraphQL client
  • SOAP client

Send mail

  • Nodemailer (smtp, password)
  • Email templates

Payment

  • PayPal
  • Stripe

Structure

  • Repository pattern
  • Module path Aliases

Authorization (Access control)

  • Role-based Access Control (RBAC)
  • Attribute-based Access Control (ABAC)
  • Can update grants at runtime
  • Implemented builder pattern

Support SEO

  • Sitemap generator
  • Google Analytics
  • Open graph

Notification

  • Self-hosted push notification
  • Store subscriptions in Redis
  • Push notification to specific users
  • Push notification to logged in users
  • Push notification to guest users
  • Unsubscribe notification
  • Firebase Cloud Messaging

I18n

  • Support EJS <%= __('home') %>, using i18n package
  • Using Cookie

File Uploader

  • Uploader decorator uploader.decorator.ts
  • Magic number checker
  • Auto resize images
  • Auto optimize images
  • Auto generate video thumbnails
  • Cloudinary
  • AWS S3

Logging

  • Log requests (using morgan)
  • Log requests in development environment
  • Write logs to file in production environment

Real-time application

  • Socket.IO
  • Redis Pub/Sub

Debugging config

  • VScode
  • JetBrains's IDEs (WebStorm, IntelliJ IDEA, ...)
  • Node Inspector

Database

  • Pagination
  • Transaction
  • Synchronizing Table Schemas
  • Data seeding
  • Multi-database

Security

  • Using helmet package
  • CORS
  • CRFS
  • Schema validation (validation pipes)
  • Rate limit
  • Check uploaded file types with magic number

Health checks

  • Get stats
  • Stats reports
  • Email health check report

Git hooks

  • Using husky
  • Linting (with lint-staged)
  • Prettier (just run yarn format)
  • Integrate Commitizen (use yarn commit instead of git commit)

Backup

  • Database backup

App containerization

  • Dockerfile (development, production)
  • Docker-compose
  • Improve image build process with buildkit
  • Kubernetes
  • Skaffold

CI/CD

  • Github actions
  • Circle CI
  • Gitlab pipeline
  • Multi-Stage pipelines

Testing

  • Unit test
  • E2E
  • Coverage
  • Performance

Documentations

  • Swagger docs http://localhost:4000/docs
  • Swagger json-docs (just append -json to Swagger path. Example: http://localhost:4000/docs-json)

About

My MRE project - built-in many features! NestJS framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 80.7%
  • Shell 11.8%
  • EJS 5.2%
  • Other 2.3%