Create an API service to receive a cep code and return an address using the viaCep API.
- Return the cep from the API and save the first search in the database
- The second time someone searchs for it, the cep should return from the database
- Use a frontend to input the cep and return the address
- Create Tests for the application
- NodeJS backend using NestJs Framework and Typescript
- Jest as the testing framework
- Swagger
- NestJS Logger
- files
.spec.ts
- unit tests - files
.e2e-spec.ts
- end to end tests
- clone the git repository
- enter
/backend
folder - run
yarn
to install the packages (if you dont have yarn, you can use npm) - run
npm start
to start the aplication - enter
/frontend
folder - run
yarn
to install the packages (if you dont have yarn, you can use npm) - run
npm start
to start the aplication
- open the terminal, access the backend folder and run the command of the chosen test type:
- to run unit tests:
npm run test:unit
- to run end to end tests:
npm run test:e2e
- to run all tests:
npm run test
If using VSCode, inside src/modules/module-name/api, you may find .http
files that works with the extension REST Client
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
- Install the extension
- Start the aplication
- Open the .http file
- Click send (replace the id when necessary)
Access http://localhost:3003/docs to view swagger documentation.
I've used clean architecture with concepts of "Domain Driven Design" (which is a design tool and not an architecture). . I've separated the context by components (modules), which also follow NestJS standards. This module separation has an monolitic backend-api in mind, wich can be easily expanded. For a micro-service (with a single context), i would bring everyting inside the modules folder foward, separating the content on their corresponding layers.
The services (usecases) contains the business rules of the application.
The frontend didnt receive too much attention, since the focus is the backend and a better ui and architecture would consume too much time.