Generic Backend Server

This is a generic backend server for web applications. It stores JSON documents and blobs (byte sequences, files). In addition, there are modules available to convert SVG files to PDF, submit user forms, send email messages, and more.

Using a generic backend, the application logic is implemented entirely in the frontend. Access rights are granted by sharing 32-hexdigit tokens.

The server runs on Debian, Ubuntu, and most other Linux distributions.

Download

Download the latest version, and place it on your server.

wget 'https://viereck.ch/backend/generic-backend-server.tar.gz'
tar xfz generic-backend-server.tar.gz

Install NodeJS:

sudo apt install nodejs

Configuration

The server comes with the following configuration file:

{ "HTTP port": 2115, "data": "var/data", "logs": "var/logs", "temporary files": "var/temp", "modules": [{ "file": "modules/PdfUniteRequests.js", "enabled": true }, { "file": "modules/SendMailRequests.js", "enabled": true }, "..." ] }

data, logs, and temporary files specify the folder where the documents, blobs, log files and temporary files are stored. The server will create these folders if necessary.

modules contains a list of enabled or disabled modules.

HTTP port specifies the TCP port on which the server listens for connections. The server accepts HTTP requests, but usually resides behind a high-performance web server, and therefore uses a non-standard port.

If you are using NginX as your main web server, configure the /backend/ location as follows:

server {
    server_name your-server.com;
    ...

    location /backend/ {
        proxy_pass  http://127.0.0.1:2115;
        proxy_set_header Host $host;
        client_max_body_size  1G;
    }
}

Starting and stopping

To quickly test the server, you can start it from the command line using:

./generic-backend-server

and stop it by pressing Ctrl-C.

The first time the server starts, it creates an empty data set. To show the root token, type:

cat var/data/root

You can copy this root token into the document editor to edit the root document.

Setting up a systemd service

To use the server in a production environment, it is highly recommended to set it up as a systemd service. To create a service description file, type:

./create-systemd-service

This will generate GenericBackendService.service, and tell you how to install and use it.

If you are running multiple instances of the Generic Backend Server on the same machine, repeat the above procedure, but choose a different name and configuration folder for each instance, e.g.

./create-systemd-service --name ViereckGenericBackendServer --wd /srv/viereck.ch/generic-backend

Client library

You can include a simple client library into your HTML page as follows:

<script src="/backend/js/Backend.js"></script>