Go to file
Werner Kroneman fd7c538244 Slightly changed the signature format.
Added a more proper error message.
2023-11-12 00:59:34 +01:00
.idea MVP seems to be working, need to test. 2023-10-15 22:16:20 -05:00
src Slightly changed the signature format. 2023-11-12 00:59:34 +01:00
.gitignore Fixed not importing lib. 2023-10-17 20:10:35 -05:00
Cargo.lock MVP seems to be working, need to test. 2023-10-15 22:16:20 -05:00
Cargo.toml MVP seems to be working, need to test. 2023-10-15 22:16:20 -05:00
flake.lock Got a basic setup going. 2023-10-14 11:57:45 -05:00
flake.nix Fixed wrong executable name. 2023-10-17 20:57:24 -05:00
leagues.toml Got a basic setup going. 2023-10-14 11:57:45 -05:00
readme.md Refactoring and documentation. 2023-10-15 22:16:20 -05:00

readme.md

Highscore REST API

The Highscore REST API is a simple application for managing highscore lists, stored in a SQLite database. The application automatically creates the database if it does not exist.

Overview

The API provides endpoints for accessing and managing highscore lists. Submitted highscores must include a valid token for verification. The token is computed as the SHA256 hash of the player name, the score, and a secret string.

Command Line Arguments

The application uses command line arguments to configure its behavior. These arguments allow you to customize the port number, database path, and submission key. Additionally, there is a --help option to display usage information. Available Options

  • --port PORT: Specifies the port number to listen on. If not provided, the default port is 3030.

  • --database PATH: Sets the path to the SQLite database file. This parameter is required for the application to function properly.

  • --submission-key KEY: Specifies the secret key used to sign highscore submissions. This parameter is also required for the application.

  • --help: Prints the help text, displaying the available options and their descriptions.

REST API Endpoints

List Highscore Lists

  • Method: GET
  • Endpoint: /highscores
  • Description: Returns a list of all available highscore lists.

Retrieve Highscore List

  • Method: GET
  • Endpoint: /highscore/<name>
  • Description: Retrieves the highscore list with the specified name.

Add Highscore Entry

  • Method: POST
  • Endpoint: /highscore/<name>
  • Description: Adds a new highscore entry to the list with the specified name.

Retrieve Highscore List for a Specific Date

  • Method: GET
  • Endpoint: /highscore/<name>/dates/<date>
  • Description: Retrieves the highscore list with the specified name and date.

Add Highscore Entry for a Specific Date

  • Method: POST
  • Endpoint: /highscore/<name>/dates/<date>
  • Description: Adds a new highscore entry to the list with the specified name and date.

Get Current Date

  • Method: GET
  • Endpoint: /date
  • Description: Returns the current date as determined by the server.

Daily Highscore List Posting Rules

For daily highscore lists, the following rules apply:

  • Highscore entries for daily lists must be submitted on the same day as the date returned by the /date endpoint, with a margin of up to two hours allowed.

Configuration

The application can be configured using the following environment variable:

  • HIGHSCORE_SECRET: The secret string used to sign highscore submissions.

Note

The concept of "daily" highscore lists has been removed from this version of the API.