Skip to content

A NestJS, GraphQL and MikroORM boilerplate code. It has auth, subscription and file uploads already implemented.

License

Notifications You must be signed in to change notification settings

adielzakaria/nestjs-graphql-monolith-template

Repository files navigation

NestJS GraphQL Boilerplate

Description

Full boiler plate of a NestJS, GraphQL and PostgreSQL (with Mikro-ORM) monolithic backend app. It implements:

  • Configuration (adds most used config classes):
    • Cache with Redis
    • GraphQL with dataloaders, subscriptions and GraphQL through Websockets
    • MikroORM with SQLite in development and PostgreSQL in production
  • Authentication:
    • JWT Authentication for HTTP
    • Custom Session Authentication for Websockets (based on Facebook Messenger Design)
    • Two-Factor authentication with email
  • Uploader:
    • Basic image only uploader with Sharp optimizations for a Linode Bucket (it can be changed for AWS S3)
  • Pagination:
    • Has the generics for Edges and Paginated types
    • A basic one way cursor pagination function

Installation

$ yarn install

Database Migrations

# creation
$ yarn migrate:create

# update
$ yarn migrate:update

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Unit Testing

BEFORE EACH TEST:

  • Check if NODE_ENV is not production
  • Remove the current test.db
  • Create a new test.db
# remove test.db
$ rm test.db

# create a new test.db
$ yarn migrate:create

EACH TEST SHOULD BE RUN SEPERATLY

# unit tests
$ yarn run test service-name.service.spec.ts --detectOpenHandles

Support the frameworks used in this template

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.

Mikro-ORM is a TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. If you like MikroORM, give it a star on GitHub and consider sponsoring its development!

Sharp is a high performance Node.js image processor. If you want to support them.

License

This template is MIT licensed.

About

A NestJS, GraphQL and MikroORM boilerplate code. It has auth, subscription and file uploads already implemented.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages