This is a sample Checkbox Service built using NestJS and GraphQL with a PostgreSQL database, and utilizing Prisma ORM for database queries.
This is a project built with NestJS and PostgreSQL, using Prisma ORM and GraphQL with a code-first approach.
Note: please go to this link for detailed improvements
- NestJS: A progressive Node.js framework for building efficient and scalable web applications.
- PostgreSQL: A powerful, open source object-relational database system.
- Prisma: A modern ORM for TypeScript and Node.js that lets you access databases with a type-safe API.
- GraphQL: A query language for APIs that provides a more efficient, powerful, and flexible alternative to REST.
- Node >= 14 <= 15
- Docker
- Docker compose
- Postgres
-
Clone this repository to your local machine
-
Install the dependencies by running
npm install
-
Run your Postgres database server.
-
Create a
.env
file at the root of projects and set the following variable
POSTGRES_USERNAME=root
POSTGRES_PASSWORD=123
POSTGRES_DB=nestjs
POSTGRES_PATH=localhost
DATABASE_URL="postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_PATH}:5432/${POSTGRES_DB}?schema=public"
-
Run
npm run setup
for first time application, this will generate necessary schema, do migration and seeding the database -
Run
npm run start:dev
to start the service in development mode -
Open http://localhost:3001/graphql in your web browser to access the GraphQL playground and explore the API.
-
Run
npx prisma studio
to run the graphical UI prisma, and open http://localhost:5555
The easiest way to run the application locally is using docker
-
Clone this repository to your local machine
-
Create a
.env
file at the root of projects and set the following variable
POSTGRES_USERNAME=root
POSTGRES_PASSWORD=123
POSTGRES_DB=nestjs
POSTGRES_PATH=postgres
DATABASE_URL="postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_PATH}:5432/${POSTGRES_DB}?schema=public"
-
Run
docker-compose up -f docker-compose-prod.yml --build
-
Run inside your docker container
docker exec -it <container_id> /bin/sh
once inside the container runnpm run seed
. To seed database (Note: make sure your database is empty first you can runnpx prisma migrate reset
to clear database).
Docker already handle everything for you