Technical test
In the project directory, you can run:
To start the app in dev mode.
For production mode
Run the test cases.
Run all test in watch mode.
You must create a .env
file in the project root folder.
You can also copy the .env.example
file and complete it with your own values.
These are the available environment variables:
# Fastify server port number
FASTIFY_PORT=2020
# Fastify addres to listen
FASTIFY_ADDRESS=0.0.0.0
# Cache ttl in seconds
CACHE_TTL_SECONDS=300
# Cache interval to clear expired records, in seconds
CACHE_CHECK_PERIOD_SECONDS=120
# OpenWheaterMap api key
OPENWEATHERMAP_APIKEY=
# OpenWheaterMap API Url
OPENWEATHERMAP_BASEURL=https://api.openweathermap.org/data/2.5/
common\
|--configSchema.js # Environment variables configuration schema
plugins\ # Fastify plugins directory
routes\ # Fastify routes directory
services\ # Services for external data access
|--openWeatherMap.js # openWeatherMap api consumer
tests\ # Tests
|--fixtures\ # Test fixtures
|--mocks\ # Test mocks
|--plugins\ # Plugins tests
|--routes\ # Routes tests`
|--services\ # Services tests
|--utils\ # Test related utils
app.js # Fastify app
Wheather check:
GET /weather/check
- get relevant weather information about an Argentinian city
- cityName - City name to check
- temperatureThreshold - Temperature in celcius to check
- temperatureCheck - returns true if the actual city temperature is equal or great than the temperature Threshold.
- cityWeather - Relevant weather info onf the city
- cityWeather.city - Name of the city
- cityWeather.description - Current wheater short description
- cityWeather.iconUrl - URL for current wheater status icon
- cityWeather.temp - City actual temperature in celcius
{
"temperatureCheck": true,
"cityWeather": {
"city": "Río Cuarto",
"description": "broken clouds",
"iconUrl": "https://openweathermap.org/img/wn/04n@2x.png",
"temp": 15.82
}
}