Added a more proper error message. |
||
---|---|---|
.idea | ||
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
flake.lock | ||
flake.nix | ||
leagues.toml | ||
readme.md |
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.