Commit 652b0614 authored by Matthieu - Greep's avatar Matthieu - Greep

Update README.md

parent e3f767d6
Pipeline #450 passed with stage
in 53 seconds
...@@ -9,45 +9,78 @@ The client can connect to the socket server via `willers.digital` on port `3201` ...@@ -9,45 +9,78 @@ The client can connect to the socket server via `willers.digital` on port `3201`
If you just want to call the REST-Server you can do it with: `https://tm-voting.willers.digital`. If you just want to call the REST-Server you can do it with: `https://tm-voting.willers.digital`.
## REST Services ## REST Services
There are currently only two REST interfaces. **All parameters MUST be done in the url query `/getVotes?map=blah`**
**POST /getMapInfo**<br> **GET /getVotes**<br>
Returns the current voting status for the current map.<br> Returns the current voting status for the current map.<br>
Example Request:
``` | Parameter | Description | Example
|------------ |------------------------------------- |-----------------------------
| map | The map UID to show the votes on it | `OkNwgzSwDLZSWSRPsUKY7EA1Cg5`
Example response:
```json
{ {
"mapId": "currentMapUId", "mapUid": "OkNwgzSwDLZSWSRPsUKY7EA1Cg5",
"userId": "UserLogin", "votes": 53,
"name": "mapname for example: Summer 2021 - 01" "average": 85,
"lastVoteDate": "2021-08-23T00:28:16.273Z"
} }
``` ```
Info: I heard that the name is not really relevant, because the API of trackmania.io already provides information about a map. Nevertheless, in the current implementation this field should at least not be null.
**POST /setVote**<br> **GET /getPlayerVote**<br>
Writes the vote of a player to the respective map into the database table. Returns the current voting status of a player for the current map.<br>
Example Request:
``` | Parameter | Description | Example
|------------ |------------------------------------- |-----------------------------
| map | The map UID to show the votes on it | `OkNwgzSwDLZSWSRPsUKY7EA1Cg5`
| player | The player login that he voted on it | `Jtmn3kBnSSadky_mLNhp_A`
Example response:
```json
{ {
"mapId": "currentMapUId", "mapUid": "OkNwgzSwDLZSWSRPsUKY7EA1Cg5",
"userId": "UserLogin", "playerLogin": "Jtmn3kBnSSadky_mLNhp_A",
"name": "mapname for example: Summer 2021 - 01", "vote": 50,
"vote": 40 "date": "2021-08-23 04:55:49.105"
} }
``` ```
**POST RESPONSE**<br>
The response is the same in both cases: **GET /mostVotedMaps**<br>
``` Returns the top most voted maps. in decreasing order (from the most voted map to the least voted map)<br>
There's no parameters for this request!
Example response:
```json
{ {
"votes": 3, "OkNwgzSwDLZSWSRPsUKY7EA1Cg5": 65,
"average": 63, "7fsfRSUCQ7YwfBEdRk_GivW6qzj": 56,
"vote": 80 "KOylxZkny8RdOEFhchN1kG6Uoo1": 32,
"n8KeykdPYEsJM6RPEZcQHVRVRIb": 32,
"RfGQDoOnJ0FiswOBjpL3V7nkF0a": 32,
"Iwo4gO_0dQ3FVQ1xeYjho5ZmLrf": 1,
} }
``` ```
If other players only listen to the current voting status on the map, the vote for the respective client is not returned, since this is client-specific and therefore not interesting for everyone. So for them the response will be like:
``` **POST /setVote**<br>
Writes the vote of a player to the respective map into the database table.<br />
⚠ You need an Authorization header with a valid token in order to do requests for this. After getting your token, set your Authorization value to `Basic yourtokenhere`
| Parameter | Description | Example
|------------ |------------------------------------- |-----------------------------
| map | The map UID to vote | `OkNwgzSwDLZSWSRPsUKY7EA1Cg5`
| player | The player login that it will vote | `Jtmn3kBnSSadky_mLNhp_A`
| vote | A number between 0 and 100 to define the vote | `56`
Example Response:
```json
{ {
"votes": 3, "mapUid": "OkNwgzSwDLZSWSRPsUKY7EA1Cg5",
"average": 63 "player": "Jtmn3kBnSSadky_mLNhp_A",
"vote": 65,
"date": "2021-08-23T03:32:18.301Z",
"type": "update" // "new" if it's a new vote, "update" if the player already voted on this map before
} }
``` ```
...@@ -82,4 +115,4 @@ The following star scale was defined for the voting plugin: ...@@ -82,4 +115,4 @@ The following star scale was defined for the voting plugin:
## Attention ## Attention
My backend is really not secure for SQL-Injection and some other secure stuff. If some more people want to use it, I should protect it more.. but that take some time. You are welcome to help me with this. That would be a nice thing if we can introduce a global map vote functionality in a secure and highly available way. :) My backend is 100% not secure for SQL-Injection and some other secure stuff. If some more people want to use it, I should protect it more.. but that take some time. You are welcome to help me with this. That would be a nice thing if we can introduce a global map vote functionality in a secure and highly available way. :)
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment