The main function of the Comment service is to create and fetch comments of a post and the count of comments.
Although noSQL database is used but a proper Schema is maintained.
Attribute | Type | Description |
---|---|---|
_id |
ObjectId |
postId of a valid Post (Primary Key) |
Attribute | Type | Description |
---|---|---|
_id |
ObjectId |
commentId of the comment (Primary Key) |
postId |
ObjectId |
postId of the post on which comment is made |
userId |
ObjectId |
userId of the user who made the comment |
text |
string |
the content of the comment |
Create a new comment on post with id postId and publishes a CommentCreatedEvent.
POST /api/comment/:postId
Get the comments on a post with id postId
POST /api/comment/:postId?anchorId=
Query Param | Type | Description |
---|---|---|
anchorId |
string |
The returned commentsId should be greater than anchorId. (pagination) |
Returns the count of comments on a post with id postId.
GET /api/comment/:postId/count
Gets the current user
POST /api/auth/currentUser
It is fired whenever a new comment is created .
Attribute | Type | Description |
---|---|---|
commentId |
string |
_id field of a valid CommentCollection document |
Handlers consumes events from NATS stream and processes them.
It captures the PostCreatedEvent and processes it and add the postId to the _id field of the ValidPostCollection .