Basic comments API for using on simple WEB apps.
- No Authentication
- Study purpose only, do not use for production
- Really, it is not intended for production, trust me
Author | Daniel Meyer Dammous |
Supports POST, GET and DELETE for /comments
endpoint
Calling endpoint with GET method will return a full array of current comments stored.
Response example (JSON):
{
"lastIndex": 2,
"data": [
{
"id": 1,
"author": "Daniel",
"comment": "Comment #1",
"date": "17/07/2022 01:51:20"
},
{
"id": 2,
"author": "Testman",
"comment": "Comment #2",
"date": "17/07/2022 01:53:39"
}
]
}
Sending a POST with a body content (comment object in JSON format) will attempt to add the new comment to the stored list.
Body example (JSON):
{ "author": "Testman", "comment": "A random comment that will be inserted on the list" }
Response will include JSON in body prop with the whole comment list, exactly the same as GET method, but with the new comment.
Note
Server will already handle adding proper values forid
anddate
.
No need to send them in the request body (will be ignored).
Send a DELETE with comment id as URL parameter to remove a comment from the stored list. Response will send whole comments list updated.
Endpoint sintax:
(...)/comments/:id
Usage example to remove comment id number 7:
(...)/comments/7
Errors will be sent as a response in the following format:
{ "error": { "internalCode": "Error_User_Input", "message": "Please do not leave any blank inputs." } }
internalCode
values are:
- Error_User_Input
- Error_Server