rewrite website

This commit is contained in:
2025-10-13 17:22:49 +02:00
parent a6d910f56a
commit 32f28e5324
263 changed files with 17904 additions and 14451 deletions

188
README.md
View File

@@ -1,42 +1,166 @@
## Quickstart
## API
To run the website locally simply execute the following commands:
> Wenn die env variable `API_SECRET` gesetzt ist, muss jede API Request den HTTP Header `Authorization: Basic <API_SECRET>` haben.
```shell
# install all dependencies
$ npm i
# run in development mode. this will start the dev server at localhost:5173
$ npm run dev
<details>
<summary><code>POST</code> <code>/api/feedback</code> (Erstellt Feedbackformulare)</summary>
##### Request Body
```
{
// Interner Event Name (oder ID)
"event": string,
// Event Titel, wird über dem Feedbackformular angezeigt
"title": string,
// UUIDs aller Spieler, die das Feedback ausfüllen sollen
"users": string[]
}
```
## Building
##### Response Codes
To build the website for production, use the following command:
| http code | beschreibung |
| --------- | ------------------------------------------ |
| 200 | / |
| 400 | Der Request Body ist falsch |
| 401 | Es wurde ein falsches API Secret angegeben |
```shell
# install all dependencies
$ npm i
# build for production. will be available in the build/ directory
$ npm run build
# run the production build.
# this will start the server at 0.0.0.0:3000, you can customize this and various other behaviors by defining environment variables. see the configuration section below for more information
$ node build/index.js
# same as 'node build/index.js' above but this loads variables from a .env file into the environment
$ node -r dotenv/config build/index.js
##### Response Body
```
{
"feedback": {
// UUID eines Spieler
"uuid": string
// URL zum Feedbackformular
"url": string
}[]
}
```
## Configuration
</details>
Configurations can be done with env variables
<details>
<summary><code>POST</code> <code>/api/report</code> (Erstellt einen Report)</summary>
| Name | Description |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HOST` | Host the server should listen on |
| `PORT` | Port the server should listen on |
| `DATABASE_URI` | URI to the database as a connection string. Supported databases are [sqlite](https://www.sqlite.org/index.html) and [mariadb](https://mariadb.org/) |
| `ADMIN_USER` | Name for the root admin user. The admin user won't be available if `ADMIN_USER` or `ADMIN_PASSWORD` is set |
| `ADMIN_PASSWORD` | Password for the root admin user defined via `ADMIN_USER`. The admin user won't be available if `ADMIN_USER` or `ADMIN_PASSWORD` is set |
| `REPORT_SECRET` | Secret which may be required (as `?secret=<secret>` query parameter) to create reports on the public endpoint. Isn't required to be in the request if this variable is empty |
| `REPORTED_WEBHOOK` | URL to send POST request to when a report got finished |
| `PUBLIC_BASE_PATH` | If running the website on a sub-path, set this variable to the path so that assets etc. can find the correct location |
| `PUBLIC_START_DATE` | The start date when the event starts |
##### Request Body
```
{
// UUID des Report Erstellers
"reporter": string,
// UUID des Reporteten Spielers
"reported": string | null,
// Report Grund
"reason": string
}
```
##### Response Codes
| http code | beschreibung |
| --------- | ----------------------------------------------------------------- |
| 200 | / |
| 400 | Der Request Body ist falsch |
| 401 | Es wurde ein falsches API Secret angegeben |
| 404 | Der Report Ersteller, oder der reportete Spieler, existiert nicht |
##### Response Body
```
{
// URL, wo der Ersteller den Report abschicken kann
"url": string
}
```
</details>
<details>
<summary><code>PUT</code> <code>/api/report</code> (Erstellt einen Abgeschlossenen Report)</summary>
##### Request Body
```
{
// UUID des Reporters. Wenn `null`, wird der Reporter als System interpretiert
"reporter": string | null,
// UUID des Reporteten Spielers
"reported": string,
// Report Grund
"reason": string,
// Inhalt des Reports
"body": string | null,
// Interne Notiz
"notice": string | null,
// Öffentliches Statement
"statement": string | null,
// ID des Strikegrundes
"strike_reason_id": number
}
```
| http code | beschreibung |
| --------- | ----------------------------------------------------------------- |
| 200 | / |
| 400 | Der Request Body ist falsch |
| 401 | Es wurde ein falsches API Secret angegeben |
| 404 | Der Report Ersteller, oder der reportete Spieler, existiert nicht |
##### Response Body
`/`
</details>
<details>
<summary><code>GET</code> <code>/api/player</code> (Status eines Spielers)</summary>
##### Request Body
```
{
// UUID eines Spielers
"user": string
}
```
| http code | beschreibung |
| --------- | ------------------------------------------ |
| 200 | / |
| 400 | Der Request Body ist falsch |
| 401 | Es wurde ein falsches API Secret angegeben |
| 404 | Der Spieler existiert nicht |
##### Response Body
```
{
// Liste aller Strikes, die der Spieler hat
strikes: {
// UTC Timestamp wann der Strike erstellt wurde
"at": number,
// Strike Gewichtung
"weight": number,
}[]
}
```
</details>
## Webhook
> Die env variable `WEBHOOK_ENDPOINT` muss gesetzt und eine valide HTTP URL sein.
Bei bestimmten Aktionen wird an den Webhook Endpoint ein Webhook gesendet.
Die Art des Webhooks wird dabei durch den `x-webhook-action` HTTP Header angegeben und hat einen festgelegten JSON Body.
Das Webhook wir so oft gesendet, bis der angegebene Webhook Endpoint eine Response mit Status `200` zurücksendet.
Alle Webhooks:
| Beschreibung | HTTP Header | Body |
| ------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- |
| Ein neuer Nutzer hat sich registriert | <pre>x-webhook-action: signup</pre> | <pre>{<br>&nbsp;&nbsp;// Vorname des Nutzers<br>&nbsp;&nbsp;firstname: string,<br>&nbsp;&nbsp;// Nachname des Nutzers<br>&nbsp;&nbsp;lastname: string,<br>&nbsp;&nbsp;//Geburtstag des Nutzers im YYYY-MM-DD format<br>&nbsp;&nbsp;birthday: string,<br>&nbsp;&nbsp;// Telefonnummer des Nutzers. `null` wenn keine angegeben wurde<br>&nbsp;&nbsp;telephone: string \| null,<br>&nbsp;&nbsp;// Spielername des Nutzers<br>&nbsp;&nbsp;username: string,<br>&nbsp;&nbsp;// Minecraft-Edition des Nutzers<br>&nbsp;&nbsp;edition: 'java' \| 'bedrock'</pre> |
| Ein neuer Report wurde erstellt | <pre>x-webhook-action: report</pre> | <pre>{<br>&nbsp;&nbsp;// Username des Reporters. `null` wenn der Report vom System gemacht wurde<br>&nbsp;&nbsp;reporter: string \| null,<br>&nbsp;&nbsp;// Username des reporteten Spielers. `null` wenn Spieler unbekannt ist<br>&nbsp;&nbsp;reported: string \| null,<br>&nbsp;&nbsp;// Grund des Reports<br>&nbsp;&nbsp;reason: string<br>}</pre> | |