The backend for Karte von morgen written in Rust.
The API is available under http://api.ofdb.io/v0/
.
The current API is documented within the openapi.yaml file. You can render the API documentation e.g. with the swagger editor:
- go to https://editor.swagger.io
- go to
File
->import URL
- enter
https://raw.githubusercontent.com/slowtec/openfairdb/master/openapi.yaml
- enjoy ;-)
An other way to see how the API can be used, you can open the network
tab in the developer
tools of your browser and see the requests that are made to https://kartevonmorgen.org
.
If you want to use the API in your project, please contact us at [email protected]. The API might still change sometimes. We will try to let you know in that case.
GET /entries/:ID_1,:ID_2,...,:ID_n
PUT /entries/:ID
GET /categories/
GET /categories/:ID_1,:ID_2,...,:ID_n
POST /ratings
GET /ratings
GET /ratings/:ID_1,:ID_2,...,:ID_n
POST /users
POST /confirm-email-address
GET /bbox-subscriptions
POST /subscribe-to-bbox
POST /unsubscribe-all-bboxes
For the following requests one must be logged in:
GET /users/:USERNAME
GET /bbox-subscriptions
POST /subscribe-to-bbox
POST /unsubscribe-all-bboxes
bbox-subscriptions
are subscriptions to a certain map area (bounding box,bbox
): whenever a new entry is created or an entry is changed within that area, an email notification is sent to the user.
Download the latest build openfairdb_x86_64-unknown-linux-musl_v0.5.1.tar.xz, unpack and start it:
wget https://github.com/slowtec/openfairdb/releases/download/v0.5.1/openfairdb_x86_64-unknown-linux-musl_v0.5.1.tar.xz
tar xJf openfairdb_x86_64-unknown-linux-musl_v0.5.1.tar.xz
RUST_LOG=info ./openfairdb
Requirements:
If you're using Ubuntu 16.04 LTS you can run
sudo apt-get install curl libssl-dev gcc
curl https://sh.rustup.rs -sSf | sh
On Windows you can download the installer from rustup.rs. (But don't forget to install a C++ toolchain first).
On Ubuntu:
sudo apt-get install sqlite3 libsqlite3-dev
cargo install diesel_cli --no-default-features --features sqlite
git clone https://github.com/slowtec/openfairdb
cd openfairdb/
diesel migration run
cargo build
./target/debug/openfairdb
The required Rust toolchain and version is defined in rustc-toolchain and will be installed by Cargo on demand when building the project.
On NixOS you can build the project with:
nix-build -E '(import <nixpkgs>{}).callPackage ./default.nix {}'
RUST_LOG=debug ./target/debug/openfairdb
If you want to get stacktraces on panics use
export RUST_BACKTRACE=1
Build and tag the Docker image:
docker build -t openfairdb:latest .
The image is created FROM scratch
and does not provide any user environment or shell.
The executable in the container is controlled by the following environment variables:
- RUST_LOG: Log level (trace, debug, info, warn, error)
- DATABASE_URL: Database file path
The database file must be placed in a volume outside of the container. For this purpose the image defines the mountpoint /volume where an external volume from the host can be mounted.
The container exposes the port 8080 for publishing to the host.
Example:
docker run --rm \
-p 6767:8080 \
-e RUST_LOG="info" \
-e DATABASE_URL="/volume/openfairdb.sqlite" \
-v "/var/openfairdb":/volume:Z \
openfairdb:latest
The resulting Docker image contains a static executable that can be extracted from any container instance:
docker cp <container id>:openfairdb .
At the moment the OpenFairDB does not support online backups. Therefore we use a simple script that copies the DB file once a day.
Note: Currently the rendered class diagram must be updated manually by uploading the contents of the file classes.puml to the PlantUML Online Editor and replace the link for the rendered diagram with one of the generated URLs.
Copyright (c) 2015 - 2018 Markus Kohlhase
This project is licensed under the AGPLv3 license.