mr4torr / nestjs-starter

Home Page:https://medium.com/geekculture/nestjs-react-next-js-in-one-mvc-repo-for-rapid-prototyping-faed42a194ca

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NestJS Starter

Opinionated NestJS MVC boilerplate for rapid development with battle-tested standards.

Use this template

Stack

It has

Usage

cp .env.example .env
docker-compose up
docker-compose exec web yarn lint
docker-compose exec db psql -U postgres -c 'create database test;'
docker-compose exec web yarn test
docker-compose exec web yarn test:e2e
docker-compose exec web yarn build

Functionality

REST endpoint via Nest

JWT-protected REST endpoint via Nest

GraphQL playground (query WhoAmI is JWT-protected)

query Public {
  things {
    id
    name
  }

  users {
    id
    provider
  }
}

# Add Header: { "Authorization": "Bearer <token>" }
query Private {
  whoAmI {
    id,
    provider,
    providerId,
    username,
    name
  }
  
  orders {
    id
    
    alias
    thing {
      name
    }
  }
}

mutation createOrder {
  createOrder(alias: "myname", thingName: "this is a thing you can order") {
    id
    alias
  }
}

Cognito auth (redirects to hosted Cognito UI)

Google auth

Next.js page

JWT-protected Next.js page

Deloyment

heroku git:remote --app <app-name>
heroku stack:set container
cp .env .env.production # Fill production values
xargs -a .env.production -I {} heroku config:set {}
heroku addons:create heroku-postgresql:hobby-dev

Useful commands

Nest CLI:

docker-compose exec web yarn nest -- --help

TypeORM CLI:

docker-compose exec web yarn typeorm -- --help

Resources

About

https://medium.com/geekculture/nestjs-react-next-js-in-one-mvc-repo-for-rapid-prototyping-faed42a194ca


Languages

Language:TypeScript 96.3%Language:JavaScript 2.5%Language:Shell 1.1%Language:Dockerfile 0.1%