Skip to content

Ismaestro/nestjs-example-app

Repository files navigation

NestJS Example App

Example app with NestJS 7 + Prisma 2 + Postgres + Graphql

👏👏🎉🎉🎉🎉👏👏

Base project made with much ❤️. Contains CRUD, advanced patterns, graphql and much more!

Demo example

ANGULAR DEMO HERE

Setup

Install dependencies first

npm i

Create a file with this content and call it .env

ENVIRONMENT=localhost

# POSTGRES
POSTGRES_HOST=localhost
POSTGRES_PORT=5433
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DATABASE=postgres
POSTGRES_SCHEMA=public

# Prisma database connection
DATABASE_URL=postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}?schema=${POSTGRES_SCHEMA}&sslmode=prefer

# Nest
PORT=3000

# Security
JWT_ACCESS_SECRET=u4ayyabkATNYWAbReNxdYF6fUcCXv4jGWn97kbcF6hnKedVf28aVZ9BEVVN6KxaUnwhWBnqzhNs7WBCDqXzSThY8fLrbGb7gxaejRBLCGDAJzU58549Tkr9a9avscJbQ33wNxa3EJhb2BwyGAkQLdNwc4Dp5BUJYhy8ewJKQGaJ35GtKA8JUDVqPbLC4HyAqNSVvH6jEXuAXCqYmU8xkdQMNmX5XBXM45b57VC78U74Dn3YB4swpy7jeSvM6fWwj
JWT_REFRESH_SECRET=W7HZVApFVRZX8LKnDr7t8S5KGSnwhszDTckq6NRTwwKp4xZKeNQQrykRTUzXRFAdudyz9rsXv5Dk43NT2cYGHKpHHXyE8dNg6nZM9v4tnz76Kz7XgnnmEm34z6cGwhQ6wGUwaHhMteKPafztZxKBbtChWdH2QKfDpR2yGfnWfTr3feACyejUKjv4a2XdPdLgaABykrcVDPh8RVkRqHNds3ACsQg5mfFdFZg9twkZUVaj2FJMGSsDNyESjpj2vhYp
JWT_EXPIRES_IN=1d
JWT_REFRESH_IN=7d

Create the postgres database

npm run docker:db

Generate the prisma schema

npm run prisma:generate

Run migrations to create necessary tables in the DB

npm run migrate:dev

Create first user and heroes

npm run seed

Start the application

npm start

What's included

  • App deployed into Fy.io.
  • CRUD: create, update and remove heroes with this project!
  • Authentication with JWT tokens
  • More logical directory structure
  • Examples of NestJS services, guards and resolvers
  • Env file included with al the environment variables that are mandatory already prepared
  • Prisma 2. Usage of prisma migrate and prisma studio.
  • Postgres to store the users and heroes of the application
  • Graphql server
  • Postman collection ready to import

Bugs and feature requests

Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Creators

Ismael Ramos

Thanks

Thanks to all contributors and their support.

If you have an idea or you want to do something, tell me or just do it! I'm always happy to hear your feedback!

Copyright and license

Code and documentation copyright 2021 the authors. Code released under the MIT License.

Enjoy 🤘