leaderboardsgg / leaderboard-backend

The backend for Leaderboards.gg. Also holds public-facing APIs.
https://info.leaderboards.gg
GNU General Public License v3.0
12 stars 16 forks source link

Restore Leaderboard Endpoint #240

Closed TheTedder closed 1 month ago

TheTedder commented 3 months ago

PUT /leaderboard/{id}/restore where {id} is a long.

The server must return a 401 error if the client is not authenticated.

The server must return a 403 error if the current user's role is not ADMIN.

The server must return a 404 error if the given ID does not correspond to a leaderboard in the database.

The server must return a 404 error if the given ID corresponds to a leaderboard that is not deleted.

The server may use a response body to disambiguate between the two different scenarios that can generate a 404 error.

The server must return a 409 error if the leaderboard cannot be restored because its slug is the same as an existing non-deleted leaderboard.

Upon a successful restoration, the server must set the DeletedAt field of the corresponding leaderboard to null and return a 204 status code.

zysim commented 1 month ago

Actually; shouldn't a non-deleted board cause a 204 instead? Basically communicate a "we didn't have to do anything" instead of a "we couldn't find it". Will implement stuff as mentioned in the issue though, in the meantime.

Eein commented 1 month ago

If the endpoint only takes deleted resource ids i think 404 is acceptable here

204 can be misconstrued that something occured