Users
GET /users
Returns all users
{
"id": 1,
"username": "rcabezas",
"email": "rcabezas@student.42madrid.com",
"avatar": "photo.jpg",
},
{
...
}
GET /users/:id
Returns one user
{
"id": 1,
"username": "rcabezas",
"email": "rcabezas@student.42madrid.com",
"avatar": "photo.jpg",
}
GET /users/avatar/:id
Returns a user’s avatar
GET /users/:id/friends
Returns a user’s friends in the UserFriend[]
format:
{
"userId": 2,
"username": "user2",
"friendshipId": 20,
"friendshipStatus": 1,
},
{
...
}
GET /users/search/:username
Searches users by a fragment of a username, and returns an array with all the partial matches.
POST /users/avatar/:id
Posts an image to replace the user’s avatar image.
Expected body: multipart/form-data
containing the image.
PATCH /users/:id
Updates a user
Expected body:
{
"username?": "apavel",
"avatar?": "photo.jpg",
"elo?": "1000",
"password?": "*********"
}
PATCH /users/role/:id
Updates a user’s role (receives an enum, see UpdateUserRoleDto
).
Expected body:
{
"role": "admin"
}
PATCH /users/:id/ban
Bans a user from the website.
No expected body.
PATCH /users/:id/unban
Unbans a user from the website.
No expected body.
DELETE /users/:id
Anonymizes a user