# Courses service
## List of events that courses-service consumes
### Register event
Description: This event is published from register service when user registers account
> exchange name: login-ex
exchange type: fanout
> queue name: course-svc-register-event-handler
```Message```
```JSON
{
"user": {
"_id": "userId",
"email": "someone@gmail.com",
"avatar": "http://avatar.com",
"username": "John smith",
"role": "STUDENT",
"student_id"
},
"event": {
"_id": "event id"
}
}
```
### Choosen documents
Description: This event is published from repository service when teacher add new documents to course
> exchange name: course-repo-ex
> exchange type: direct
> queue name: course-svc-repository-event-handler
> key: document.chosen.list
```Message```
```JSON
{
data: {
"courseId": "9a602267-b217-47b9-a931-ab762004e2af",
"course"
"user_id": "",
"documents": {
"count": 1,
"documents":
[
{
"document_name": "HTML Basic",
"document_description": "Welcome to the world of code! Last year, millions of learners from our community started with HTML. Why? HTML is the skeleton of all web pages.",
"document_type": "SHAREDLINK",
"document_subject": "HTML"
"document_path": "https://drive.google.com/file/d/1X1HwCIvWBXarb6Vt8D9LY7ZrA2t6VA6S/view?usp=sharing",
}
]
}
},
"event": {
"_id": "eventId"
}
}
}
```
## List of events that courses-service publish
### Comment in an course
Description: This event is published when comment is created by user
> exchange name: notification-ex
> exchange type: direct
> biding key: course.comment
> queue name: notification-svc-course-event-handler
```Message```
```JSON
{
"comment": {
"_id": "commentId",
"commentator_id": "userId",
"commentator_name": "Trần Tú Hảo",
"course_id": "courseId",
"course_name": "web nâng cao"
},
"event": {
"_id": "eventId"
}
}
```
### Reply a comment in an course
Description: This event is published when comment is reply by user
> exchange name: notification-ex
> exchange type: direct
> binding key: course.replyComment
> queue name: notification-svc-course-event-handler
```Message```
```JSON
{
"comment": {
"_id": "commentId",
"comment_parent": "commentId",
"comment_parent_owner_id": "userId",
"comment_parent_owner_email": "tuhao@gmail.com",
"commentator_id": "userId",
"commentator_name": "Trần Tú Hảo",
"course_id": "courseId",
"course_name": "web nâng cao"
},
"event": {
"_id": "eventId"
}
}
```
### Create a new course
Description: This event is published when a new course is created by teacher
> exchange name: notification-ex
> exchange type: direct
> binding key: course.created
> queue name: notification-svc-course-event-handler
```Message```
```JSON
{
"course": {
"_id": "commentId",
"course_name": "web nâng cao"
},
"event": {
"_id": "eventId"
}
}
```
### Update course
Description: This event is published when teacher updates a course
> exchange name: notification-ex
> exchange type: direct
> binding key: course.update
> queue name: notification-svc-course-event-handler
```Message```
```JSON
{
"course": {
"_id": "commentId",
"course_name": "web nâng cao"
},
"event": {
"_id": "eventId"
}
}
```
### Delete course
Description: This event is published when a course is deleted
> exchange name: notification-ex
> exchange type: direct
> binding key: course.delete
> queue name: notification-svc-course-event-handler
```Message```
```JSON
{
"course": {
"_id": "commentId"
},
"event": {
"_id": "eventId"
}
}
```