You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jonas Lochmann e68ca95320
Add documentation for purchases to the readme
2 weeks ago
other Initial commit 11 months ago
scripts Remove sign in with Google account 5 months ago
src Add simple CSRF protection for the admin API 6 days ago
.gitignore Initial commit 11 months ago
Dockerfile Initial commit 11 months ago
LICENSE Initial commit 11 months ago Add documentation for purchases to the readme 6 days ago
package-lock.json Update dependencies 2 months ago
package.json Update dependencies 2 months ago
tsconfig.json Initial commit 11 months ago
tslint.json Initial commit 11 months ago


This is the server for the connected mode in TimeLimit.


This application only supports running a single instance of it. When clustering, push messages do not work anymore between devices connected to different devices and the rate limiting is per instance.


Option 1: Build (run sudo docker build -t timelimit-server . in this directory) and use a docker image
Option 2: Install Node.JS (see below for detailed usage)


npm start

This runs all pending migrations and starts the server.

npm run build

This “compiles” the application.

npm run lint:fix

This fixes the causes of lint warnings (where possible).

Configuration (environment variables)

    • this specifies the database to use
    • default value: sqlite://test.db (sqlite database in the source code directory)
    • supports mysql, postgresql and sqlite (sqlite in development builds only because it’s declared as dev dependency)
    • looks like postgres://
    • no extra setup needed
      • when starting the application, the database tables are created/ migrated
      • this only works for upgrading; if you intend to eventually downgrade, make a backup first (you should make backups in all cases before an upgrade)
  • PORT
    • the port at which the server should listen
    • should be set to production in production
    • when using development, then mails are not sent; instead they are written to a html file which is opened
    • key for validating purchases
    • purchases using google play don’t work without it
    • sender (for the from-field) for sent mails
    • a string which is added to the footer of the sent mails
    • default value: not defined
    • a password which allows to use some APIs
    • admin APIs are disabled when this is not set
    • list of domains, separated by comma
    • if the user tries to use such a mail service, then he will get the notification that this provider is not supported


This server application itself does not support HTTPS. You have to use an other tool to use HTTPS. One options for this is to use nginx with the following site config:

# don't forget to update the port for your local configuration
# the max_fails is important - otherwise nginx
# marks the server sometimes as unreachable if it is restarted
# or starts after nginx
upstream timelimitbackend {
  server localhost:8080 max_fails=0;

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  # don't forget to update the domain
  server_name my.domain;

  # don't forget to update the paths
  ssl_certificate /my/fullchain.pem;
  ssl_certificate_key /my/privkey.pem;

  # eventually configure the SSL parameters here

  location / {
    proxy_pass http://timelimitbackend/;

    client_max_body_size 10m;
    # the following is required for websocket support
    # without websockets, the client will not detect
    # that there is a connection and it will not sync
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;

Admin API

When the ADMIN_TOKEN environment variable was set, then there is a admin API available at http(s)://server/admin. This page is protected using HTTP basic authentication. The username is ignored, the password is the admin token.

This allows to:

  • see the counter for the websocket connections
  • set a status message which is shown at all linked clients at the overview screen
  • unlock the premium version feature for a user for a month or a year


To enable the automated purchase feature, set the GOOGLE_PLAY_PUBLIC_KEY environment variable. The value for the official builds which are distributed using the Play Store can be found at

Additionally, there is the admin API which allows one to unlock the premium features.