TODO: Add description here!
- GraphQL w/ playground
- Code-First w/ decorators
- Prisma for database modelling, migration and type-safe access (Postgres, MySQL & MongoDB)
- 🔐 JWT authentication w/ passport-jwt
- REST API docs w/ Swagger
# 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
Install the dependencies for the Nest application:
npm install
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
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
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
Execute the script with this command:
yarn prisma:seed
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
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 accessToken
as followed to HTTP HEADERS in the playground and replace YOURTOKEN
here:
{
"Authorization": "Bearer YOURTOKEN"
}
Or just go to <http://localhost:3000/auth/google
RESTful API documentation available with Swagger.
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
You can use common linting scripts
# lint
yarn lint
# typecheck
yarn typecheck
# format
yarn format
# test
yarn test
View current database state with prisma studio
yarn prisma studio
# or
yarn prisma:Studio
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