Skip to content

sheldon-welinga/relay-api

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

Description

Nest framework TypeScript starter repository.

This folder is discover bookings applications api. It will be based on the MVC model

Technologies

  • Nestjs & @nestjs/typeorm
  • Graphql-relay
  • Typeorm & @nestjs/typeorm
  • Graphql

Architecture

MVC architecture where each folder will be named as per the table e.g. user

  • user.resolver.ts - contains graphql queries and mutations for said table e.g. user
  • user.service.ts - Contains all the functionalities that will interact with the reposiory folder
  • user.module.ts - Our core folder which will be injected to our root app module

The general lib folder will contain all other functionalities e.g. It will contain

  • repository - This is the folder that will interact with our DB
  • entities - This folder will contain our DB tables, we will use the old tables from db folder
  • migrations - The DB migrations will be created here
  • graphql - The graphql schema
  • connections - the relay connections
  • types - Custom types that are reusable
  • utils - Any shared utils

naming conventions will be <modulename>.<foldername>.ts

TDD

This backend system will be based on TDD (Test Driven Development) appraoch and its therefore required to write tests for different api's and ensure all tests are passing before being merged Tests should be written in the test folder while other codes are written in the src folder

Migration

The configuration for migrations is made in the src/config/datasource.config.ts

Due to the new typeorm features follow below steps to run migrations

Running Migrations

  • Open the src/config/datasource.config.ts
  • Update the value of synchronize to true (This will automatically run current migrations)
  • Afterwards turn this value back to false

Generating a migration

  • First ensure that the value synchronize in src/config/datasource.config.ts is false
  • Create a new entity table in src/lib/entities
  • Run yarn migration:generate <migrations directory/migration-name> e.g. yarn migration:generate src/lib/migrations/create-user-entity

NB: To run the above migration follow the previous step on Running migrations

Installation

$ yarn install

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Test

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

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.

Stay in touch

License

Nest is MIT licensed.