This project is an API for calculating details of a trip, including travel time, fuel cost, carbon emissions, and weather conditions along the route.
- Calculate distance and travel time between two locations.
- Calculate fuel cost for the trip.
- Calculate carbon emissions for the trip based on fuel type.
- Obtain weather conditions at the origin and destination points.
- Node.js v14 or higher. You can download it here
- NPM. You can install it by following the instructions here para NPM.
- Google Maps API account and key. You can obtain a Google Maps API key by following the instructions here
The API documentation is automatically generated by Swagger. After starting the server, you can access the interactive documentation at http://localhost:3000/api-docs.
- Clone the repository:
git clone https://github.com/AysllaGomes/distance-calculator.git
cd seu-repositorio
- Install dependencies:
npm install
- Configure the Google Maps API key. Create a .environment.ts file in the project config and add your API key:
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
OPEN_WEATHER_MAP_API_KEY=your_open_weather_map_key
- To start the development server:
npm run start:dev
- Endpoint:
{
"origin": "Planaltina, Goiás, Brasil",
"destination": "Conceição da Aparecida, Minas Gerais, Brasil",
"fuelConsumption": 10,
"fuelPrice": 5.80,
"averageSpeed": 77,
"drivingStartTime": "09:00",
"drivingEndTime": "18:00",
"departureDate": "2024-06-07",
"fuelTankSize": 50, // optional
"restTime": 3, // optional
"fuelType": "ethanol" // optional
}
"origin": "Origin location"
"destination": "Destination location"
This project is licensed under the MIT License. See the LICENSE file for more details.