Nest Logo

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


Getting started

First you must to clone the repository using:

$ git clone 'https://github.com/caiquetorres/graphql-example-nestjs.git'

After that install all the required dependencies with:

$ npm install -g @nestjs/cli

$ npm install

This project uses husky's commit-msg hook. For using it run the following commands:

$ npx husky install

$ npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'

Running the app

# development
$ nest start

# watch mode
$ nest start --watch

# production mode
$ nest start --prod

Docker

The application uses Docker for running some examples of databases.

Obs: Using the ".env.{database}.example" files you can copy the configuration found in those and put it in the ".env" file.

For using Postgres

$ sudo docker-compose up -d posgres

For using MySQL

$ sudo docker-compose up -d mysql

Migrations

For creating a new migration run the command:

$ npm run typeorm:migrate MIGRATION_NAME

And for executing all the migrations run:

$ npm run typeorm:run

Structure

Always, when creating a new entity, create a folder in 'src/modules' with the entity name (Ex: 'src/modules/product' ). Inside the folder, it must have the following structure:

  • product
    • dtos (All the dtos related with products)
      • create-product.input.ts
      • update-product.input.ts
      • query-product.args.ts
    • entities (All the entities related with products)
      • product.entity.ts
    • resolvers (All the resolvers related with products)
      • product-relations.resolver.ts
      • product.resolver.ts
    • services (All the services related with products)
      • product-relations.service.ts
      • product.service.ts
    • product.module.ts

Sentry

The application is also integrated with Sentry this way it allows tracking exceptions and storing them.


License

Paperbook API is MIT licensed.