Before starting, make sure you have at least those components on your workstation
Start by cloning this project in your workstation
git clone /~https://github.com/lukzfreitas/challenge-backend-nestjs
The next thing, you'll need install all dependencies of the the project
npm install
After install all dependencies, you can now configure enviroments variable, to do this you need create a file .env with variables below
MONGODB_DB_URI = <YOUR_URL_DATABASE_MONGODB>
JWT_SECRECT_KEY = <YOUR_SECRET_KEY>;
If you followed steps previous so you're ready to run your application using the command below
npm run start:dev
Now you can access swagger and see all endpoint available to you in api. All endpoint is protected by authorization using lib passport. You need create a user and catch up token in body response and then set header in endpoint that you want use as such example below
To create a new user http://localhost:3000/user
Request
POST /users HTTP/1.1
Host: localhost:3000
Content-Type: application/json
{
"username": <YOUR_USERNAME>,
"password": <YOUR_PASSWORD>
"email": <YOUR_EMAIL>
}
And login http://localhost:3000/login
POST /login HTTP/1.1
Host: localhost:3000
Content-Type: application/json
{
"username": <YOUR_USERNAME>,
"password": <YOUR_PASSWORD>
}
Response
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
So you can pass by parameter in the endpoint localhost:3000/expense Bearer authetication such as exemple below
GET /expense HTTP/1.1
Host: localhost:3000
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
In construction soon more details...
The goal of this project is improvement my skills such as backend developer using framework NestJs and share my knowledge with another developers.
The following improvements are currently in progress :
- Implementation API REST
- Implementation new features
- Security and deploy API
- Project structure documentation
- Discovery more improvements
Fell free to suggest an improvement, report a bug, or ask me something /~https://github.com/lukzfreitas/challenge-backend-nestjs/issues