Create Post
Endpoint (URL): /api/v1/posts
HTTP Request Method: POST
Request Body:
{
"description": <DESC>,
"image": <IMG>
}
Success Response Body:
{
"success": "true",
{
"id": <ID>,
"description": <DESC>,
"image": <IMG>,
"createdAt": <DATE>
}
}
Fail Response Body:
{
"success": "false",
"message": "Description And Image Fields Are Null! Fill One Field At Least"
}
Get All Posts
Endpoint (URL): /api/v1/posts
HTTP Request Method: GET
Success Response Body:
{
"success": "true",
"posts": [
{
"id": <ID1>,
"description": <DESC>,
"image": <IMG>,
"createdAt": <DATE>
},
{
"id": <ID2>,
"description": <DESC>,
"image": <IMG>,
"createdAt": <DATE>
}
]
}
Get Post
Endpoint (URL): /api/v1/posts/:id
HTTP Request Method: GET
Success Response Body:
{
"success": "true",
{
"id": <ID>,
"description": <DESC>,
"image": <IMG>,
"createdAt": <DATE>
}
}
Fail Response Body:
{
"success": "false",
"message": "Fill One Field At Least"
}
Update Post
Endpoint (URL): /api/v1/posts/:id
HTTP Request Method: PUT
Request Body:
{
"description": <DESC>,
"image": <IMG>
}
Success Response Body:
{
"success": "true",
{
"id": <ID>,
"description": <DESC>,
"image": <IMG>,
"createdAt": <DATE>
}
}
Fail Response Body:
{
"success": "false",
"message": "Description And Image Fields Are Null! Fill One Field At Least"
}
Delete Post
Endpoint (URL): /api/v1/posts/:id
HTTP Request Method: DELETE
Success Response Body:
{
"success": "true",
"message": "Post With ID <ID> Has Been Deleted"
}
Fail Response Body:
{
"success": "false",
"message": "There is no Comment With The ID <ID> !"
}
Add Comment
Endpoint (URL): /api/v1/posts/:id/comments/:id
HTTP Request Method: POST
Request Body:
{
"content": <COMMENT_CONTENT>
}
Success Response Body:
{
"success": "true",
{
"id": <ID>,
"content": <COMMENT_CONTENT>,
"createdAt": <DATE>
}
}
Fail Response Body:
{
"success": "false",
"message": "Content Field Can't be Null! Fill Content Field Please"
}
Get All Comments
Endpoint (URL): /api/v1/posts/:id/comments
HTTP Request Method: GET
Success Response Body:
{
"success": "true",
"comments": [
{
"id": <ID1>,
"content": <COMMENT_CONTENT>,
"createdAt": <DATE>
},
{
"id": <ID2>,
"content": <COMMENT_CONTENT>,
"createdAt": <DATE>
}
]
}
Update Comment
Endpoint (URL): /api/v1/posts/:id/comments/:id
HTTP Request Method: PUT
Request Body:
{
"content": <COMMENT_CONTENT>
}
Success Response Body:
{
"success": "true",
{
"id": <ID>,
"content": <COMMENT_CONTENT>,
"createdAt": <DATE>
}
}
Fail Response Body:
{
"success": "false",
"message": "Fill One Field At Least"
}
Delete Comment
Endpoint (URL): /api/v1/posts/:id/comments/:id
HTTP Request Method: DELETE
Success Response Body:
{
"success": "true",
"message": "Comment With ID <ID> Has Been Deleted"
}
Fail Response Body:
{
"success": "false",
"message": "There is no Comment With The ID <ID> !"
}