Shipment service is a simple API Rest that calculates the price of each shipping quote available to a given zipcode.
It has been used for the mobile app Sertton where the user can calculate the price based on their zipcode before buying an item on the e-commerce.
This API Rest uses Melhor Envio API under the hood, a free shipment plataform that intermediates several brazilian shipping companies.
- This API should be authenticated by Melhor Envio API using OAuth protocol, where the former should behave client and resource server
- This API should request to Melhor Envio refresh the auth token every week on Sunday 00:00
- This API should validate the access token before sending to Melhor Envio API
- This API should store both access token and refresh token in cache
- This API should return the shipping quotes based on Sertton's zipcode and the customer's zipcode and price, quantity and dimensions of the requested products (width, height, weight and length)
-
NodeJs to run JavaScript on server side
-
Melhor Envio to provide shipping service quote
-
Redis to store the tokens in cache for the authentication
-
Fastify to build the API server
-
Node Cron to refresh token by cron-time job scheduler
-
Axios to make HTTP request to Melhor Envio API
-
Vitest to make unit tests
For more details about the project's dependencies like specific versions of each dependency, see package.json
Before download the prject you will need install some tools:
-
(Optional) Docker, the amazing technology to manage containers.
Besides that, it is good to have some tool to write the code like VSCode
Also it is pivotal setting the environment variables on the
.env
file before running the application. See the .env.example file to know which variables should be set
# Clone this repo
$ git clone https://github.com/JohnPetros/shipment-service.git .
# Install the node dependencies
$ pnpm install
# Run the application on a development environment
$ pnpm dev
# Start the redis docker container (optional)
$ docker compose up
Probably the aplication will be running on http://localhost:3333
This application's deploy was made using Rende plataform, which means you can use the running application accessing this link.
# Fork this repo
$ git clone https://github.com/JohnPetros/shipment-service.git
# Create a nem branch for the new feature
$ git checkout -b new-feature
# Commit your changes:
$ git commit -m 'feat: <New Feature>'
# Push your branch:
$ git push origin new-feature
You must replace new-feature with the name the feature you are adding
You can also open a new issue about some problem, question or sugestion for the project. I will be happy to help as well as improve this application
This application is under MIT Licence. See the licence file to get more details about it.
Made with 💜 by John Petros 👋🏻