mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
cleaned doc & friends provided with display names
This commit is contained in:
155
doc/user/friend.md
Normal file
155
doc/user/friend.md
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
# Friend
|
||||||
|
|
||||||
|
Available endpoints:
|
||||||
|
- POST `/users/:userId/friends`
|
||||||
|
- GET `/users/:userId/friends`
|
||||||
|
- GET `/users/:userId/friends/count`
|
||||||
|
- DELETE `/users/:userId/friends`
|
||||||
|
- DELETE `/users/:userId/friends/:friendId`
|
||||||
|
|
||||||
|
Common return:
|
||||||
|
- 500 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "Internal server error"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## POST `/users/:userId/friends/:friendId`
|
||||||
|
|
||||||
|
Used to add a friend to an user
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"msg": "Friend added successfully"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if no user is specified in header, or friend is the user specified in header, or friend is already added)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist, or friend does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 401 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## GET `/users/:userId/friends?iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
||||||
|
|
||||||
|
Used to get the friends of an user
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response (list of friend objects (between iStart and iEnd))
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"friends":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"friendName": "<the friend's username>",
|
||||||
|
"friendDisplayName": "<the friend's display name>"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if iStart/iEnd is missing, or iEnd < iStart)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist, or no friends exist in the selected range)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## GET `/users/:userId/friends/count`
|
||||||
|
|
||||||
|
Used to get the number of friends of an user
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"n_friends": <number of friends>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## DELETE `/users/:userId/friends`
|
||||||
|
|
||||||
|
Used to delete the friends of an user
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"msg": "Friends deleted successfully"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 401 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## DELETE `/users/:userId/friends/:friendId`
|
||||||
|
|
||||||
|
Used to delete a friend of an user
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"msg": "Friend deleted successfully"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 401 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist, or friend does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
148
doc/user/matchHistory.md
Normal file
148
doc/user/matchHistory.md
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# Match History
|
||||||
|
|
||||||
|
Available endpoints:
|
||||||
|
- POST `/users/:userId/matchHistory`
|
||||||
|
- GET `/users/:userId/matchHistory`
|
||||||
|
- GET `/users/:userId/matchHistory/count`
|
||||||
|
- DELETE `/users/:userId/matchHistory`
|
||||||
|
|
||||||
|
Common return:
|
||||||
|
- 500 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "Internal server error"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## POST `/users/:userId/matchHistory?game=<pong/tetris>`
|
||||||
|
|
||||||
|
Used to add a match result to an user to a specific game
|
||||||
|
|
||||||
|
Input needed :
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"game": "<pong/tetris>"
|
||||||
|
"opponent": "<the opponent's username>",
|
||||||
|
"myScore": <my score>,
|
||||||
|
"opponentScore": <the opponent's score>,
|
||||||
|
"date": <seconds since Epoch (Date.now() return)>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"msg": "Match successfully saved to the blockchain"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if no user is specified in header, or no opponent/p1Score/p2Score is specified in body, or opponent is the user specified in header, or a score is negative, or the game specified is invalid)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist, or opponent does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 401 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## GET `/users/:userId/matchHistory?game=<pong/tetris>&iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
||||||
|
|
||||||
|
Used to get the match history of an user for a specific game
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response (list of matches results (between iStart and iEnd))
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"matchHistory":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"score":
|
||||||
|
{
|
||||||
|
"p1": "<the name of the p1>",
|
||||||
|
"p2": "<the name of the p2>",
|
||||||
|
"p1Score": "<the score of the p1>",
|
||||||
|
"p2Score": "<the score of the p2>",
|
||||||
|
"date": <seconds since Epoch (Date.now() return)>
|
||||||
|
},
|
||||||
|
"tx": "<the transcaction hash>"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if iStart/iEnd does not exist, or iEnd < iStart, or the game specified is invalid)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist, or no matches exist in the selected range)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## GET `/users/:userId/matchHistory/count?game=<pong/tetris>`
|
||||||
|
|
||||||
|
Used to get the number of matches an user played for a specific game
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"n_matches": <number of matches played by the user>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if game does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## DELETE `/users/:userId/matchHistory?game=<pong/tetris>`
|
||||||
|
|
||||||
|
Used to delete the match history of an user for a specific game
|
||||||
|
|
||||||
|
Can return:
|
||||||
|
- 200 with response
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"msg": "Match history deleted successfully"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 400 with response (if user specified in header is neither admin nor user, or the game specified is invalid)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 401 with response (if user specified in header is neither admin nor user)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 404 with response (if user does not exist)
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": "<corresponding error>"
|
||||||
|
}
|
||||||
|
```
|
||||||
280
doc/user/user.md
280
doc/user/user.md
@ -2,21 +2,12 @@
|
|||||||
|
|
||||||
Available endpoints:
|
Available endpoints:
|
||||||
- POST `/users/:userId`
|
- POST `/users/:userId`
|
||||||
- POST `/users/:userId/friends`
|
|
||||||
- POST `/users/:userId/matchHistory`
|
|
||||||
- GET `/users`
|
- GET `/users`
|
||||||
- GET `/users/count`
|
- GET `/users/count`
|
||||||
- GET `/users/:userId`
|
- GET `/users/:userId`
|
||||||
- GET `/users/:userId/friends`
|
|
||||||
- GET `/users/:userId/friends/count`
|
|
||||||
- GET `/users/:userId/matchHistory`
|
|
||||||
- GET `/users/:userId/matchHistory/count`
|
|
||||||
- PATCH `/users/:userId/:member`
|
- PATCH `/users/:userId/:member`
|
||||||
- DELETE `/users/:userId`
|
- DELETE `/users/:userId`
|
||||||
- DELETE `/users/:userId/:member`
|
- DELETE `/users/:userId/:member`
|
||||||
- DELETE `/users/:userId/friends`
|
|
||||||
- DELETE `/users/:userId/friends/:friendId`
|
|
||||||
- DELETE `/users/:userId/matchHistory`
|
|
||||||
|
|
||||||
Common return:
|
Common return:
|
||||||
- 500 with response
|
- 500 with response
|
||||||
@ -57,77 +48,6 @@ Can return:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## POST `/users/:userId/friends/:friendId`
|
|
||||||
|
|
||||||
Used to add a friend to an user
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"msg": "Friend added successfully"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if no user is specified in header, or friend is the user specified in header, or friend is already added)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist, or friend does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 401 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## POST `/users/:userId/matchHistory?game=<pong/tetris>`
|
|
||||||
|
|
||||||
Used to add a match result to an user to a specific game
|
|
||||||
|
|
||||||
Input needed :
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"game": "<pong/tetris>"
|
|
||||||
"opponent": "<the opponent's username>",
|
|
||||||
"myScore": <my score>,
|
|
||||||
"opponentScore": <the opponent's score>,
|
|
||||||
"date": <seconds since Epoch (Date.now() return)>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"msg": "Match successfully saved to the blockchain"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if no user is specified in header, or no opponent/p1Score/p2Score is specified in body, or opponent is the user specified in header, or a score is negative, or the game specified is invalid)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist, or opponent does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 401 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## GET `/users?iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
## GET `/users?iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
||||||
|
|
||||||
Used to get the list of users
|
Used to get the list of users
|
||||||
@ -206,116 +126,6 @@ Can return:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## GET `/users/:userId/friends?iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
|
||||||
|
|
||||||
Used to get the friends of an user
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response (list of friend objects (between iStart and iEnd))
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"friends":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"friendName": "<the friend's username>"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if iStart/iEnd is missing, or iEnd < iStart)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist, or no friends exist in the selected range)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## GET `/users/:userId/friends/count`
|
|
||||||
|
|
||||||
Used to get the number of friends of an user
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"n_friends": <number of friends>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## GET `/users/:userId/matchHistory?game=<pong/tetris>&iStart=<starting index (included)>&iEnd=<ending index (excluded)>`
|
|
||||||
|
|
||||||
Used to get the match history of an user for a specific game
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response (list of matches results (between iStart and iEnd))
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"matchHistory":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"score":
|
|
||||||
{
|
|
||||||
"p1": "<the name of the p1>",
|
|
||||||
"p2": "<the name of the p2>",
|
|
||||||
"p1Score": "<the score of the p1>",
|
|
||||||
"p2Score": "<the score of the p2>",
|
|
||||||
"date": <seconds since Epoch (Date.now() return)>
|
|
||||||
},
|
|
||||||
"tx": "<the transcaction hash>"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if iStart/iEnd does not exist, or iEnd < iStart, or the game specified is invalid)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist, or no matches exist in the selected range)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## GET `/users/:userId/matchHistory/count?game=<pong/tetris>`
|
|
||||||
|
|
||||||
Used to get the number of matches an user played for a specific game
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"n_matches": <number of matches played by the user>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if game does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## PATCH `/users/:userId/:member`
|
## PATCH `/users/:userId/:member`
|
||||||
|
|
||||||
Used to modify a member of an user (only displayName can be modified)
|
Used to modify a member of an user (only displayName can be modified)
|
||||||
@ -400,93 +210,3 @@ Can return:
|
|||||||
"error": "<corresponding error>"
|
"error": "<corresponding error>"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## DELETE `/users/:userId/friends`
|
|
||||||
|
|
||||||
Used to delete the friends of an user
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"msg": "Friends deleted successfully"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 401 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## DELETE `/users/:userId/friends/:friendId`
|
|
||||||
|
|
||||||
Used to delete a friend of an user
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"msg": "Friend deleted successfully"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 401 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist, or friend does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## DELETE `/users/:userId/matchHistory?game=<pong/tetris>`
|
|
||||||
|
|
||||||
Used to delete the match history of an user for a specific game
|
|
||||||
|
|
||||||
Can return:
|
|
||||||
- 200 with response
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"msg": "Match history deleted successfully"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 400 with response (if user specified in header is neither admin nor user, or the game specified is invalid)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 401 with response (if user specified in header is neither admin nor user)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- 404 with response (if user does not exist)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "<corresponding error>"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@ -8,10 +8,16 @@ export async function gFriends(request, reply, fastify, getUserInfo, getFriends)
|
|||||||
if (Number(iEnd) < Number(iStart)) {
|
if (Number(iEnd) < Number(iStart)) {
|
||||||
return reply.code(400).send({ error: "Starting index cannot be strictly inferior to ending index" });
|
return reply.code(400).send({ error: "Starting index cannot be strictly inferior to ending index" });
|
||||||
}
|
}
|
||||||
const friends = getFriends.all(userId, Number(iEnd) - Number(iStart), Number(iStart));
|
const friendNames = getFriends.all(userId, Number(iEnd) - Number(iStart), Number(iStart));
|
||||||
if (!friends.length) {
|
if (!friendNames.length) {
|
||||||
return reply.code(404).send({ error: "No friends exist in the selected range" });
|
return reply.code(404).send({ error: "No friends exist in the selected range" });
|
||||||
}
|
}
|
||||||
|
const promises = friendNames.map(async (friendName) => {
|
||||||
|
const friend = getUserInfo.get(friendName.friendName);
|
||||||
|
friendName.friendDisplayName = friend.displayName;
|
||||||
|
return friendName;
|
||||||
|
});
|
||||||
|
const friends = await Promise.all(promises);
|
||||||
return reply.code(200).send({ friends });
|
return reply.code(200).send({ friends });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fastify.log.error(err);
|
fastify.log.error(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user