What is the purpose of this API?
This API serves as a simple NestJS boilerplate for both my personal reference and for others to use :)
What concepts are covered in this API?
Attention: insert all commands line in /api-nestjs-bp path in your terminal
pnpm install
# copy the `.env.example` to an `.env` file
cp .env.example .env
.env
fields, especially the fields under the # PostgreSQL database configs
comment# To create a container and scaffold it in the background process
docker-compose up -d
or
docker compose up -d
pnpm prisma db push
Create a hash to be your JWT public key
openssl rand -base64 32
pnpm start
Note: the following name and email was generated automatically by 4devs
curl -X POST http://localhost:3000/users -H 'Content-Type: application/json' -d '{"name": "Marcos Felipe Ian Lopes", "email": "marcos@email.com", "password": "1234"}'
Login using the password and user created in last step
curl -X POST http://localhost:3000/api/auth/login -H 'Content-Type: application/json' -d '{"email": "marcos@email.com", "password": "1234"}'
Insert the generated token where is it the curly braces (remove the curly braces)
curl -X GET http://localhost:3000/posts -H 'Content-Type: application/json' -H "Authorization: Bearer {token}"
If everythihg is alright you should see a single square bracket: "[]"
If you prefer, download and use the insomnia specific collection located in /collection
folder
Note that the .env.example
has some S3 environment variables, just replace them to start using with your own bucket