You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 25, 2023. It is now read-only.
when requesting invalid resources (ID, collection, etc.)
405
Method Not Allowed
e.g. when attempting to PUT a collection endpoint
413
Payload Too Large
not sure if you have a real 10KB limit, but would apply in that case
429
Too Many Requests
you don't state that you rate limit, but including this anyway
Error
Code
Description
Uses
500
Internal Server Error
generic
503
Service Unavailable
I saw issues in the past with Mongo Atlas problems
Body
The response body would also benefit from being standardized with static or conditional fields. As a suggestion, you could provide the following standard response fields on the body:
status (one of: "success", "fail", or "error")
message (when status is "fail" or "error": a description of the error or the reason why the request failed)
data (when status is "success"—might not used in cases like DELETE unless you return the deleted data in the response)
Here's an example response for a PUT request with an invalid ID:
{
"status": "fail",
"message": "Invalid record ID"
}
To extend this further, you could also consider implementing a caching mechanism using Etags, and utilizing the 304 status code. However, that might be best discussed in a separate issue.
It would be useful to standardize and document the responses for each operation, such as the status code, response body, etc.
Status codes
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
Here are some suggested examples:
Success
create
requestsFail
PUT
a collection endpointError
Body
The response body would also benefit from being standardized with static or conditional fields. As a suggestion, you could provide the following standard response fields on the body:
status
(one of: "success", "fail", or "error")message
(whenstatus
is "fail" or "error": a description of the error or the reason why the request failed)data
(whenstatus
is "success"—might not used in cases likeDELETE
unless you return the deleted data in the response)Here's an example response for a PUT request with an invalid ID:
And here's one for a GET request:
The text was updated successfully, but these errors were encountered: