Note : This is an unfinished project And Docs Is Not Complete
POST /api/users
Create a new user.
Content-Type: application/json
{
"username": "yourusername",
"email": "youremail@example.com",
"password": "yourpassword"
}
{
"token": "YOUR\_JWT\_TOKEN"
}
GET /api/users/me
Get current user's details.
x-auth-token: YOUR\_JWT\_TOKEN
{
"_id": "USER_ID",
"username": "yourusername",
"email": "youremail@example.com",
"followingCount": 0,
"followersCount": 0,
"followers": [],
"following": []
}
POST /api/auth
Authenticate user and get token.
Content-Type: application/json
{
"email": "youremail@example.com",
"password": "yourpassword"
}
{
"token": "YOUR\_JWT\_TOKEN"
}
POST /api/posts
Create a new post.
Content-Type: application/json
x-auth-token: YOUR\_JWT\_TOKEN
{
"title": "Post Title",
"content": "Post content"
}
{
"_id": "POST_ID",
"user": "USER_ID",
"title": "Post Title",
"content": "Post content",
"date": "2024-06-24T12:00:00.000Z",
"comments": []
}
GET /api/posts
Get all posts.
[
{
"_id": "POST\ID",
"user": {
"_id": "USER_ID",
"username": "userusername"
},
"title": "Post Title",
"content": "Post content",
"date": "2024-06-24T12:00:00.000Z",
"comments": []
}
]
POST /api/comments/:postId
Add a comment to a post.
Content-Type: application/json
x-auth-token: YOUR\_JWT\_TOKEN
{
"text": "This is a comment"
}
[
{
"_id": "COMMENT_ID",
"user": "USER_ID",
"text": "This is a comment",
"date": "2024-06-24T12:00:00.000Z",
"replies":\[]
}
]
POST /api/comments/:postId/:commentId/replies
Add a reply to a comment or a nested reply.
Content-Type: application/json
x-auth-token: YOUR\_JWT\_TOKEN
{
"text": "This is a reply to a comment or a nested reply"
}
[
{
"_id": "REPLY_ID",
"user": "USER_ID",
"text": "This is a reply to a comment or a nested reply",
"date": "2024-06-24T12:00:00.000Z",
"replies": []
}
]
GET /api/comments/:postId
Get comments and replies for a post.
\[
{
"\_id": "COMMENT\_ID",
"user": {
"\_id": "USER\_ID",
"username": "commenterusername"
},
"text": "This is a comment",
"date": "2024-06-24T12:00:00.000Z",
"replies": \[
{
"\_id": "REPLY\_ID",
"user": {
"\_id": "REPLY\_USER\_ID",
"username": "replyusername"
},
"text": "This is a reply",
"date": "2024-06-24T12:00:00.000Z",
"replies": \[
// Nested replies
\]
}
\]
}
\]
PUT /api/users/:id/follow
Toggle follow/unfollow a user.
x-auth-token: YOUR\_JWT\_TOKEN
{ "msg": "Followed/Unfollowed successfully" }