Simple application for university.
Application is written on Fastify.
- Install dependencies
$ npm i
- Run service in development mode with live-reload
$ npm run dev
Run the test cases.
$ npm run test
Locally application is running on http://127.0.0.1:3000
URL Params: city: string
-> any city name
โ 200 - Returns random forecast
{
"success":true,
"data": {
"city":"Tartu",
"temperature":3,
"wind":2,
"precipitation":"๐ฆ๏ธ"
}
}
โ400 - Bad request - 30% of requests will be failed with this error
{
"success":false,
"data":null,
"error":"Something went wrong. Please try again"
}
BODY Params: city: string
-> allowed city name
โ 200 - Returns random forecast for city
{
"success":true,
"data": {
"city":"Tartu",
"temperature":3,
"wind":2,
"precipitation":"๐ฆ๏ธ"
}
}
โ404 - Not Found - if provided city not found
{
"success": false,
"data": null,
"error": "City not found in the list. Allowed cities are: Tartu, Tallinn, Berlin, Barcelona, Paris, Copenhagen, Helsinki, Riga"
}
NOTE:
- Response is stringified JSON
โ 200 - Returns random magnitude for city, every 2000ms
{
"city": "Tartu",
"magnitude": 4.6
}