jaiminho
jaiminho copied to clipboard
Rest application for zip codes from Brazil.
jaiminho
Rest application for zip codes from Brazil.

Dependencies
Using Docker
If you want to use docker, just install it and run in this directory:
./jaiminho build
After that, install NodeJS packages:
./jaiminho install
And, after installation, run:
./jaiminho start
To see all commands:
./jaiminho help
To run in debug mode:
./jaiminho debug
To run tests:
./jaiminho test
To run a specific command:
./jaiminho run <command>
Note: If above commands don't work, you need to give execution permission for the ./jaiminho file:
chmod +x ./jaiminho
Without using docker
You need to install nodemon and istanbul globally:
[sudo] npm i -g nodemon istanbul
Now, you need to install project dependencies with command:
npm i
Running
Run jaiminho in debug mode with command:
npm run nodemon
Data model
jaiminho accepts the following fields:
- cep
- tipoDeLogradouro
- logradouro
- bairro
- cidade
- estado
Adding zip codes
curl -H "Content-Type: application/json" -X POST -d '{"cep":"76873274","tipoDeLogradouro":"Rua","logradouro":"Juriti","bairro":"Setor 02","cidade":"Ariquemes","estado":"RO"}' http://localhost:3000/cep
Response:
'{"message":"76873274 succesfully inserted!"}'
Getting zip codes
curl -X GET http://localhost:3000/cep/76873274
Response:
'{"cep":"76873274","tipoDeLogradouro":"Rua","logradouro":"Juriti","bairro":"Setor 02","cidade":"Ariquemes","estado":"RO"}'
Error response:
'{"error":"CEP 76873274 not found"}'
Updating an existent zip code
curl -H "Content-Type: application/json" -X PUT -d '{"cep":"76873274","tipoDeLogradouro":"Rua","logradouro":"Juritingueta","bairro":"Setor 02","cidade":"Ariquemes","estado":"RO"}' http://localhost:3000/cep/76873274
Response:
'{"message":"76873274 successfully updated!"}'
Deleting an existent zip code
curl -X DELETE http://localhost:3000/cep/76873274
Response:
'{"message":"76873274 succesfully removed!"}'