Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| wiki:software:beuthbot:mensa-service [13.12.2019 09:59] Christopher Lehmann | wiki:software:beuthbot:mensa-service [24.01.2020 15:12] (aktuell) Tolga Karaoglu [Versioning] | ||
|---|---|---|---|
| Zeile 5: | Zeile 5: | ||
| ==== Table of content ==== | ==== Table of content ==== | ||
| - | - [[wiki: | + | - [[wiki: | 
| - [[wiki: | - [[wiki: | ||
| - [[wiki: | - [[wiki: | ||
| Zeile 14: | Zeile 14: | ||
| - [[wiki: | - [[wiki: | ||
| - [[wiki: | - [[wiki: | ||
| - | - [[wiki: | + | - [[wiki: | 
| - | - [[wiki: | + | |
| - [[wiki: | - [[wiki: | ||
| - [[wiki: | - [[wiki: | ||
| - [[wiki: | - [[wiki: | ||
| - | - [[wiki: | + | - [[wiki: | 
| - [[wiki: | - [[wiki: | ||
| - [[wiki: | - [[wiki: | ||
| Zeile 30: | Zeile 29: | ||
| === Prerequisites === | === Prerequisites === | ||
| - | - [[https:// | + | - [[https:// | 
| - [[https:// | - [[https:// | ||
| === Cloning === | === Cloning === | ||
| - | Get the source code by cloning its repository via https: [[https:// | + | Get the source code by cloning its repository via https: [[https:// | 
| === Installing === | === Installing === | ||
| - | After cloning the repository, you will need to make sure that you have node and npm installed on your working system. To check if you already have node installed, try | + | After cloning the repository, you will need to make sure that you have node and npm installed on your working system. To check if you already have node installed, try\\ | 
| - | + | \\ | |
| - | `node --version` | + | '' | 
| - | + | \\ | |
| - | Same for checking if npm is installed, just with npm instead of the node command | + | Same for checking if npm is installed, just with npm instead of the node command\\ | 
| - | + | \\ | |
| - | `npm --version` | + | '' | 
| - | + | ||
| - | If you don't have node or npm installed, download the Softare via the links provided in [Prerequisites](# | + | |
| - | + | ||
| - | After that install all necessesary dependencies | + | |
| - | + | ||
| - | `npm install` | + | |
| - | + | ||
| - | Now you can start the local development server to play around with the API and make your calls | + | |
| - | + | ||
| - | `npm run dev` | + | |
| - | + | ||
| - | This will fire up a development server that listens on port 8000. | + | |
| + | If you don't have node or npm installed, download the software via the links provided in [[wiki: | ||
| + | \\ | ||
| + | After that install all necessesary dependencies in the directory where the package.json exists\\ | ||
| + | \\ | ||
| + | '' | ||
| + | \\ | ||
| + | Now you can start the local development server to play around with the API and make your calls\\ | ||
| + | \\ | ||
| + | '' | ||
| + | \\ | ||
| + | This will fire up a development server that listens on port 8000.\\ | ||
| + | \\ | ||
| If you direct your browser to http:// | If you direct your browser to http:// | ||
| - | ## Overview | + | ==== Overview | 
| - | The mensa microservice is basically a _Node_-_Express_-Backend. Incoming requests are checked and specifically handled. | + | The mensa microservice is basically a //Node//-//Express//-Backend. Incoming requests are checked and specifically handled. | 
| - | ### Structure | + | ==== Structure | 
| - | 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, | + | The microservice consists of four folders containing several scripts, which are designated to perform certain tasks. 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, | 
| - | ### Functionalities | + | ==== Functionalities | 
| - | On request, this microservice makes calls to the [OpenMensa API](https:// | + | On request, this microservice makes calls to the [[https:// | 
| - | #### The scripts-folder | + | ==== Project structure ==== | 
| - | This folder contains two scripts, that will be called by a cron job once a day. Probably early in the morning. `getMealsOfTheDay.js` makes a request to the [OpenMensa API](https:// | + | === The services-folder | 
| - | + | ||
| - | #### The services-folder | + | |
| This folder consists of several services, that perform specific tasks for the microservice. | This folder consists of several services, that perform specific tasks for the microservice. | ||
| - | ###### | + | == generateResponse.js | 
| Creates a nicely formatted string from a mensa-JSON-object and caches it. | Creates a nicely formatted string from a mensa-JSON-object and caches it. | ||
| - | ###### mealService.js | + | == mealsOfSpecificDay.js == | 
| - | Makes a request to the OpenMensa-API and caches the response. It can also filter the file for specific meals. For example only vegetarian or vegan meals, etc. | + | Makes a request to the OpenMensa API and filters by given entities (for instance | 
| - | ###### mealsOfSpecificDayService.js | + | === The routes-folder | 
| - | + | ||
| - | If a day other than the current day is requested, we need to make another request to the OpenMensa-API, | + | |
| - | + | ||
| - | #### The routes-folder | + | |
| 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 `/ | 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 `/ | ||
| Zeile 100: | Zeile 92: | ||
| The `/ | The `/ | ||
| - | ## Further Development | + | ==== Further Development | 
| This is still a work in progress, so functionalities and structure might still change during development | This is still a work in progress, so functionalities and structure might still change during development | ||
| - | ## Further Reading | + | ==== Further Reading | 
| - | + | ||
| - | - [OpenMensa API](https:// | + | |
| - | + | ||
| - | ## Built With | + | |
| - | - [Node.js](https://nodejs.org/en/) | + | - [[https://doc.openmensa.org/api/v2/|OpenMensa API]] | 
| - | - [Express.js](https: | + | |
| - | - [Axios](https:// | + | |
| - | ## Versioning | + | ==== Built With ==== | 
| - | We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/< | + | - [[https://nodejs.org/en/|Node.js]]\\ | 
| + | - [[https://expressjs.com/|Express.js]]\\ | ||
| + | - [[https://www.npmjs.com/ | ||
| - | ## Authors | + | ==== Versioning ==== | 
| - | - **Tolga Karaoglu** | + | We use [[http:// | 
| - | - **Steven Sobkowski** | + | |
| - | See also the list of [contributors](https:// | + | ==== Authors ==== | 
| + | - **Tolga Karaoglu**\\ | ||
| + | - **Steven Sobkowski**\\ | ||
| + | \\ | ||
| + | See also the list of [[https:// | ||
| + | <WRAP pagebreak></ | ||