For this week assignment, i'm trying to make an authentication/authorization using session token on RESTAPI that i've been created on week 13 so only users that already registered can access the resource endpoint.
In order to run this project locally, you need to clone this repository first using git clone
$ https://github.com/revou-fsse-1/w14-my-authorized-api-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"
services:
postgres:
image: postgres:14
ports:
- 5432:5432
environment:
- POSTGRES_DB=revou
- POSTGRES_USER=revou
- POSTGRES_PASSWORD=password
volumes:
- ./postgres-data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=password
ports:
- 15432:80
don't forget to create .env
files on root folder same like before with these command:
DATABASE_URL="postgresql://revou:password@localhost: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
You can follow my documentation on postman
: Link
- First of all, all you need to do is registering your email and password first using the following links
-
RestAPI
register
Links : https://w14-security-dandirizky.onrender.com/auth/register|| Register Endpoint || POST /auth/register
- After that, you can login with email and password that you registered before
-
RestAPI
login
Links : https://w14-security-dandirizky.onrender.com/auth/login|| Login Endpoint || POST /auth/login
- After you successfully login, you can access the resources endpoint such as
users
andproducts
.
-
RestAPI
users
Links : https://w14-security-dandirizky.onrender.com/users|| Users Endpoint || GET /users
-
RestAPI
products
Links : https://w14-security-dandirizky.onrender.com/products|| Products Endpoint || GET /products GET /products/1 POST /products PUT /products/1 PATCH /products/1 DELETE /products/1
- Anddd for the last step.. dont forget to logout :)
-
RestAPI
logout
Links : https://w14-security-dandirizky.onrender.com/auth/logout|| Logout Endpoint || POST /auth/logout
- NestJS
- Typescript
- PrismaORM
- PostgreSQL
- Docker
- Postman
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.