aboutsummaryrefslogtreecommitdiffstats

BoodschAPI - RESTful API for Boodschappen (Grocery shopping in Dutch)

BoodschAPI is a RESTful API with an embedded front-end for desktop and mobile to manage weekly shopping chores. It is a Spring Boot application, deployed using maven.

Database

BoodschAPI can run on its own without a web server, but it does depend on a database. I use MariaDB. Setting up MariaDB itself is beyond the scope of this text, but once you have, use mysql-create.sql to create the database schema and populate reference data.

Next, put a file called application.properties inside src/main/resources/ with these contents:

spring.datasource.url=jdbc:mysql://<hostname>/<boodschapi-db>?useSSL=false
spring.datasource.username=<db-user>
spring.datasource.password=<db-password>

Do not add this file to git (it is mentioned in .gitignore) since it will contain sensitive info.

The same goes for your users, which go into a file users.properties in the same folder, like this:

user=password

The passwords must be bcrypt encoded.

If you don't use MariaDB or MySQL, adapt the database script and put a dependency on your database driver in the pom file. Consider sending a pull request upstream.

Running BoodschAPI

You can deploy BoodschAPI on its own using:

$ mvn spring-boot:run

If you're using Linux, use the systemd unit boodschapi.service that is in the root of this project. It will daemonize the application so you can leave it running without staying logged in. Copy it to where your system expects it. (i.e. /etc/systemd/system/ on Arch Linux).

Installation

Put the app's contextPath in applications.properties, or leave it commented when you run it in its own (sub)domain:

server.contextPath=/[path]

As a Spring Boot app BoodschAPI can run itself, but if you prefer an encrypted connection you can let Nginx or Apache handle that.

Nginx

Put a config file in Nginx' config include directory (usually /etc/nginx/conf.d/) with these contents:

upstream tomcat {
    server localhost:8080;
}

server {
    listen 80;
    server_name sub.domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name sub.domain.com;

    location / {
        proxy_pass http://tomcat;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

    # include logging & encryption settings here...
}

Apache

After configuring Apache for ssl/https, enable mod_proxy and

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Add proxy settings to the virtual host configured for ssl:

ProxyPass /[path] ajp://localhost:9090/[path]
ProxyPassReverse /[path] ajp://localhost:9090/[path]

Latest

You can find the latest version of BoodschAPI at https://code.diederickdevries.net/boodschapi/

No feature/bug reports please, only pull requests. Refer to https://code.diederickdevries.net/?p=about will tell you how to do that.