Skip to content

Latest commit

 

History

History
82 lines (58 loc) · 2.23 KB

README.md

File metadata and controls

82 lines (58 loc) · 2.23 KB

Comment Service

The main function of the Comment service is to create and fetch comments of a post and the count of comments.


Database (comment)

Although noSQL database is used but a proper Schema is maintained.

ValidPostCollection


Attribute Type Description
_id ObjectId postId of a valid Post (Primary Key)

CommentCollection


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

API Reference

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

Events

CommentCreatedEvent

It is fired whenever a new comment is created .

Attribute Type Description
commentId string _id field of a valid CommentCollection document

Handlers

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 .


Architecture Diagram

comment