/flixtracker

TV shows & movies tracker project

Primary LanguageTypeScript

Instructions

TODO: Add description here!

Tech

Overview

Setup

TL;DR

  # 1) copy .env.example as .env
  # 2) install
  yarn install
  # 3) run db & maildev
  yarn docker:dev
  # 4) run prisma migration
  yarn prisma:save
  yarn prisma:up
  yarn prisma:seed # if you want

  # 4) run app
  yarn start

1. Install Dependencies

Install the dependencies for the Nest application:

npm install

2. PostgreSQL with Docker

Setup a development PostgreSQL with Docker. Copy example.env and rename to .env which sets the required environments for PostgreSQL such as DB_USER, DB_USER and DB_USER. Update the variables as you wish and select a strong password.

Start the PostgreSQL database

docker-compose -f docker-compose.db.yml up -d
# or
npm run docker:db

3. Prisma: Prisma Migrate

Prisma Migrate is used to manage the schema and migration of the database. Prisma datasource requires an environment variable DB_URL for the connection to the PostgreSQL database.

Saving the migration of the database:

yarn prisma migrate save --experimental
# or
yarn run prisma:save

Perform the database migration:

yarn prisma migrate up --experimental
# or
yarn prisma:up

4. Prisma: Prisma Client JS

Prisma Client JS is a type-safe database client auto-generated based on the data model.

Generate Prisma Client JS by running

Note: Every time you update schema.prisma re-generate Prisma Client JS

yarn prisma generate
# or
yarn prisma:generate

5. Seed the database data with this script

Execute the script with this command:

yarn prisma:seed

6. Start NestJS Server

Run Nest Server in Development mode:

yarn start

# watch mode
yarn start:dev

Run Nest Server in Production mode:

yarn start:prod

GraphQL Playground for the NestJS Server is available here: http://localhost:3000/graphql

Usage

1. GraphQL Playground

Open up the example GraphQL queries and copy them to the GraphQL Playground. Some queries and mutations are secured by an auth guard. You have to acquire a JWT token from signup or login. Add the accessTokenas followed to HTTP HEADERS in the playground and replace YOURTOKEN here:

{
  "Authorization": "Bearer YOURTOKEN"
}

Or just go to <http://localhost:3000/auth/google

2. Rest Api & Swagger Docs

RESTful API documentation available with Swagger.

3. Docker

You can also setup a the database and Nest application with the docker-compose

# building new docker images
yarn docker:build

# start docker compose (needs some env setup)
yarn docker

# start only dependencies (without nest app itself)
yarn docker:dev

3. Scripts

You can use common linting scripts

# lint
yarn lint

# typecheck
yarn typecheck

# format
yarn format

# test
yarn test

4. Prisma Studio

View current database state with prisma studio

yarn prisma studio
# or
yarn prisma:Studio

5. Schema Development

Update the Prisma schema prisma/schema.prisma and after that run the following two commands:

yarn prisma generate
# or in watch mode
yarn prisma generate --watch
# or
yarn prisma:generate
yarn prisma:generate:watch