NestJS GraphQL API example with unit and e2e tests.
I use pnpm
as my node manager, you can use whatever you like, simply remove the pnpm-lock.yaml file and use npm|yarn
instead.
The following scripts are here to help you get up and running in a development environment as quickly as possible.
$ pnpm install
Example .env file
POSTGRES_USER=postgres
POSTGRES_PASSWORD=super-secret-secure-password
POSTGRES_DB=coffedb
# Prisma
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?schema=public
# CORS
ALLOWED_ORIGINS=http://localhost:3000/
Then run
# start the docker db
$ pnpm start:dev:db
# migrate the schema
$ pnpx prisma migrate deploy
# seed the database
$ pnpx prisma db seed
$ ts-node generate-typings.ts
# Will run on port 5000
$ pnpm start:dev
Open http://localhost:5000/graphql
# unit tests
$ pnpm test
# e2e tests
$ pnpm test:e2e
# test coverage
$ pnpm test:cov