For this week assignment, i'm trying to containerizing the apps from week 14 using docker and creating beautiful documentation using swagger.
My Docker Hub Images : https://hub.docker.com/r/dandirizkyy/w15-dandi-myapp
In order to run this project locally, you need to clone this repository first using git clone
$ https://github.com/revou-fsse-1/w15-my-backend-extra-DandiRizkyy.git
then run pnpm install
in your terminal to download all dependencies
$ pnpm install
create docker-compose.yaml
on root folder (where the package.json installed) and fill with these commands to install postgresql database locally on your computer
version: '3.9'
services:
database:
image: postgres:alpine
container_name: dandirizky-mydatabase
hostname: database
volumes:
- postgres:/var/lib/postgresql/data
ports:
- 5432:5432
env_file:
- .env
restart: always
app:
image: dandirizkyy/dandirizky-w15-myapp
container_name: dandirizky-myapp
build: .
ports:
- 4001:4001
env_file:
- .env
depends_on:
- database
restart: always
volumes:
postgres:
don't forget to create .env
files on root folder same like before with these command:
DATABASE_URL="postgresql://revou:password@database:5432/revou?schema=public"
and run docker with these command:
docker-compose up -d
after that you can start the server using these following command :
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
if you want to stop docker, you can use these command
docker-compose stop
Here you can find my documentation using swagger : https://w15-webapp-dandi.onrender.com/docs
- First of all, all you need to do is registering your email and password first.
-
register
|| Register Endpoint || POST /auth/register { "email": "[email protected]", "password": "example123" }
- After that, you can login with email and password that you registered before
-
login
|| Login Endpoint || POST /auth/login { "email": "[email protected]", "password": "example123" }
- After you successfully login, you can access the resources endpoint such as
users
andproducts
.
-
users
|| Users Endpoint || GET /users
-
products
|| Products Endpoint || GET /products -------------------- GET /products/1 -------------------- POST /products { "title": "Example Title", "description": "Example Description", "category": "Example Category", "userId": 1 } -------------------- PUT /products/1 { "title": "Example Title", "description": "Example Description", "category": "Example Category", "userId": 1 } -------------------- PATCH /products/1 *Optional field, you can change either one value or multiple value at once { "title": "Example Title", "description": "Example Description", "category": "Example Category", "userId": 1 } -------------------- DELETE /products/1
- Anddd for the last step.. dont forget to logout :)
-
logout
|| Logout Endpoint || POST /auth/logout
- NestJS
- Swagger
- Typescript
- PrismaORM
- PostgreSQL
- Docker
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil MyΕliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.