ka-mensa-api is one component in a three-part project whose goal it is to
aggregate, process and visualize the Studierendenwerk Karlsruhe's canteen plans
in ways superior to the official sources.
Disclaimer: This project is neither affiliated with nor endorsed by the Studierendenwerk Karlsruhe or the Karlsruhe Institute of Technology.
The entire project is written in JavaScript+TypeScript and is composed as follows:
Ensure Node and NPM are available on your system. Then clone this repository
somewhere and run npm install to load dependencies.
Open up config.ts and configure to your liking. Notice that network options
are rather limited. If you want HTTPS support, CORS headers or advanced
embedding into existing domain structures, you will need to set up a reverse
proxy like nginx.
You might want to change the plan fetch source. This will not impact ka-mensa-api's behavior but only how it retrieves its data. There are two options available:
'simplesite' (the default)'jsonapi'The simplesite source fetches plans from the Studierendenwerk's website, which offers a view for the visually impaired that is quite easy to parse. It allows for fetching plans far into the future and is relatively stable. That said, this still breaks sometimes, e.g. when the Studierendenwerk renames lines or takes other unpredictable actions.
The JSON API source is more reliable. It will basically never break. The downside: it requires authentication (you will have to figure out how to obtain credentials on your own).
In summary, both sources provide the same information but differ in stability and auth requirements.
To start the server, run npm start. It will immediately fetch the most recent
set of plans, then listen for API requests. Plan polling will continue
indefinitely with the interval set in config.ts.
Note that npm start is shortcut for npm run build followed by npm run production,
where the former compiles the TypeScript code and the latter executes it.
To start the server without compiling again, use npm run production only.
This project is available as a Docker image! See also https://hub.docker.com/r/meyfa/ka-mensa-api.
If you just want to get going:
docker run --name mensa -p <host-port>:8080 -d meyfa/ka-mensa-api
If you would like to put the cache in a volume (highly recommended!) so it has
enough room to grow, is available after restarting the container and/or can be
accessed from the host: Mount to /usr/src/app/cache like so:
docker run \
--name mensa \
-p <host-port>:8080 \
-v /path/on/host:/usr/src/app/cache \
-d meyfa/ka-mensa-api
Perhaps you need to configure CORS for the API server - to enable displaying
the plans via an instance of ka-mensa-ui running on another domain, for
example. This can be done via the config file or by setting an environment
variable:
docker run \
--name mensa \
-p <host-port>:8080 \
-v /path/on/host:/usr/src/app/cache \
-e API_SERVER_CORS_ALLOWORIGIN=https://example.com \
-d meyfa/ka-mensa-api
Specify a regular URL to only allow that one origin. Use * to allow all
origins.
Contributions are welcome. Guidelines:
npm testnpm run lintnpm run lint-fixA document outlining the API provided by this software is available: API_DOCUMENTATION.md.
Content type
Image
Digest
sha256:8342b1fce…
Size
65 MB
Last updated
6 days ago
docker pull meyfa/ka-mensa-api