One Day workshop on understanding the Nestjs framework and to build the basic CRUD operation with postgres database.
- Basic knowledge of docker and docker-compose
- Basics of express-app
- Which is covered in Workshop 1 Go through this repo if you haven't completed it
- preferred Tools:
- IDE: VS Code - Download Link
Note: Install using apt - API client for REST : Insomnia - Download link
- IDE: VS Code - Download Link
- Fork Workshop2 repository into your account.
- Clone repo into your local machine run the follwing commands
- Create a folder
GITHUB
$ mkdir GITHUB $ cd GITHUB
- Clone your repository
Note WebApp-Workhop2 folder is created.$ git clone git@github.com:<your-username>/WebApp-Workshop2.git
$ cd WebApp-Workshop2
- Add upstream
$ git remote add upstream git@github.com:UniCourt/WebApp-Workshop2.git
- Create a branch called
dev
in your local
$ git fetch --all $ git checkout -b dev upstream/main
- Create a folder
-
Open terminal and naviagte to
/GITHUB/WebApp-Workshop2/
-
Build the docker images
$ docker-compose build --no-cache
-
Setup Postgres
- Bring up the Postgres docker service
$ docker-compose up -d service-workshop-postgres
- Import database schema
$ docker exec -i workshop-postgres psql -h localhost -U workshop_user -d nest_app < database/master.sql
- You should get a message
CREATE TABLE
- Verify by logging into the database
$ docker exec -ti workshop-postgres psql -h localhost -U workshop_user -d nest_app nest_app=# \d
- Note: The command
\d
will list all the relations.
-
Bring up the NestJS Application
-
Open new tab in the terminal
/GITHUB/WebApp-Workshop2/
-
Bring up the NestJS and Postgres application using docker-compose
$ docker-compose up -d
-
Execute into NestJS container to run the server
$ docker exec -ti workshop-nestjs /bin/sh /app # npm run start:dev
-
Open http://localhost:3000 on your browser
-
You will get a message
-
To close the application open new tab in the terminal
/GITHUB/WebApp-Workshop2/
$ docker-compose down
- By the end of this workshop you will understand Nest framework structure.
- Controller, Module and Service in NesjJS
- Connection to Database
- Basic CRUD operation with NestJS