Navigation
Über uns
Externe Inhalte
Navigation
Über uns
Externe Inhalte
Dies ist eine alte Version des Dokuments!
Der Wetter Mikroservice ist ein Dienst, welche aktuell über den Telegram Client angesprochen wird. Dabei kann der Service per Chat einfach angesprochen werden ohne das der User im Vorfeld etwas einrichten muss. Dieser Dienst antwortet dabei auf Fragen, welche das Wetter im Allgemeinen, aber auch im Stündlichen betreffen, ebenso wie das vergangene Wetter. Aktuell ist eine Anfrage von bis zu 7 Tage in der Zukunft, sowie 5 Tage in der Vergangenheit möglich. Ab 47 Stunden in der Zukunft kann der Bot nur noch mit dem allgemeinen Wetter antworten, sprich keine stündliche anfrage.
The weather microservice is basically a Node-Express-Backend. Incoming requests are checked and specifically handled. It can give you a general forecast for the next five days or a detailed forecast for the current day.
The microservice consists of four folders containing several scripts, which are designated to perform certain tasks. We have the *scripts*-folder containing scripts, that will be called by cron-jobs mainly for caching purposes. Then we have the *services*-folder containing files, that consist of functions useful to process incoming requests from the chatbot and to generate a formatted answer-string, that contains the weather forecast for Berlin. The *routes*-folder consists of all the routes, that can be addressed. In the next chapters we will get into more details about the scripts and their functions.
On request, this microservice makes calls to the OpenWeatherMap API. The received data is processed by services that return a nicely formatted string containing the weather forecast for Berlin. Mainly this service was built throughout the Masterprojekt module that is a mandatory part of the media informatics master course of the Beuth University for Applied Sciences.
This folder contains two scripts, that will be called by a cron job multiple times a day, since we can only do a maximum of 60 requests to the API per day. getWeather.js
makes a request to the OpenWeatherMap API and caches the answer. After that writeResponseFile.json
is called and generates a pretty formatted answer-string. Now everytime a User wants to know the current weather forecast, we can just read it out of the cached data and don't need to call the API.
This folder consists of several services, that perform specific tasks for the microservice.
Creates a nicely formatted string from a weather-JSON-object and caches it.
Makes a request to the OpenWeatherMap-API
to get the current weather forecast and stores the response.
If a weather forecast for the next days is requested, than this script requests the necessary data from the OpenWeatherMap-API
and stores its response.
This folder contains all the routes, that can be addressed on this server. The index.js
manages all the routes. We've only got two routes in our project. The /swagger
-route leads you to the swagger documentation of this project. The /weather
-route will be called by another component of the Beuthbot. It expects a message object containing the necessary details for this service. It then calls all the functions needed to perform requests and generates an answer, which is finally send back as a response to the Chatbot.
This is still a work in progress, so functionalities and structure might still change during development
- Node.js
- Express.js
- Axios
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Tolga Karaoglu
- Steven Sobkowski
See also the list of contributors who participated in this project.