---
# System prepended metadata

title: Pure js service

---

# Pure js service

## List of events that pure-js-service publishes

### Notification Service

<span style="color:#58a6ff">1. pjs.exercise.created binding key</span>

Description: This event is published when exercise is created by teacher
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    { 
        "exercise": {
            "_id": "exerciseId",
            "exercise_name": "BTCN 1: Understand HTML structure",
            "exercise_deadline": 2324545,
            "creator_id": "userId",
            "creator_name": "Nguyễn Đức Huy",
            "course_id": "courseId"
        },
        "event": {
            "_id": "event id"
        }
    }
```

<span style="color:#58a6ff">2. pjs.exercise.update binding key</span>

Description: This event is published when exercise is updated by teacher
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    { 
        "exercise": {
            "_id": "exerciseId",
            "exercise_name": "BTCN 1: Understand HTML structure",
            "exercise_deadline": 2324545,
            "course_id": "courseId"
        },
        "event": {
            "_id": "event id"
        }
    }
```

<span style="color:#58a6ff">3. pjs.exercise.delete binding key</span>

Description: This event is published when exercise is deleted by teacher
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    { 
        "exercise": {
            "_id": "exerciseId",
        },
        "event": {
            "_id": "event id"
        }
    }
```

<span style="color:#58a6ff">4. pjs.exercise.submit binding key</span>

Description: This event is published when exercise is submitted by student
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    { 
        "exercise": {
            "_id": "exerciseId",
            "submitter_id": "userId",
            "submitter_name": "Trần Tú Hảo",
            "submitter_email": "tuhao99@gmail.com"
        },
        "event": {
            "_id": "event id"
        }
    }
```

<span style="color:#58a6ff">5. pjs.exercise.remark binding key</span>

Description: This event is published when exercise is remarked by teacher
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    { 
        "exercise": {
            "_id": "exerciseId"
        },
        "event": {
            "_id": "event id"
        }
    }
```


<span style="color:#58a6ff">6. pjs.exercise.comment binding key</span>

Description: This event is published when exercise is commented by user
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```Message```

```json=
    {
        "comment": {
          "_id": "commentId",
          "commentator_id": "userId",
          "commentator_name": "Trần Tú Hảo",
          "exercise_id": "exerciseId",
          "exercise_name": "layout với CSS"
        },
        "event": {
            "_id": "eventId"
        }
    }
```


<span style="color:#58a6ff">7. pjs.exercise.replyComment binding key</span>

Description: This event is published when a comment is replied by user
> exchange name: <b>notification-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>notification-svc-pjs-event-handler</b>

```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",
          "exercise_id": "exerciseId",
          "exercise_name": "layout với CSS"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

### Exercise Aggregator service

Description: This event is published when pure a pure javasrcipt exercise is created, updated or deleted
> exchange name: <b>exercise-aggregator-ex</b>

>exchange type: <b>topic</b>

> queue name: 
* <b>exercise-aggregator-svc-pure-javascript-event-handler</b>
    * Binding key: <b>pure.javascript.*</b>

1. <span style="color:#58a6ff;">pure.javascript.created routing key</span>
```Message```

```json=
    {
        "exercise": {
            "_id": "exerciseId",
            "exercise_name": "BTCN 1: Understand HTML structure",
            "exercise_deadline": 121313213132,
            "exercise_type": "PURE_JAVASCRIPT",
            "course_id": "courseId"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

2. <span style="color:#58a6ff;">pure.javascript.updated routing key</span>
```Message```

```json=
    {
        "exercise": {
            "_id": "exerciseId",
            "exercise_name": "BTCN 1: Understand HTML structure",
            "exercise_deadline": 121313213132,
            "exercise_type": "PURE_JAVASCRIPT"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

3. <span style="color:#58a6ff;">pure.javascript.deleted routing key</span>
```Message```

```json=
    {
        "exercise": {
            "_id": "exerciseId"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

Description: This event is published when a solution is created, submitted or marked.
> exchange name: <b>solution-aggregator-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>exercise-aggregator-svc-solution-event-handler</b>


1. <span style="color:#58a6ff;">solution.created binding key</span>


```Message```

```json=
    {
        "solution": {
            "_id": "solutionId",
            "created_at": 313213215654,
            "user_id": "userId",
            "exercise_id": "exerciseId"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

2. <span style="color:#58a6ff;">solution.submitted binding key</span>

```Message```

```json=
    {
        "solution": {
            "_id": "solutionId",
            "solution_submitted": true,
            "updated_at": 123465465464
        },
        "event": {
            "_id": "eventId"
        }
    }
```

3. <span style="color:#58a6ff;">solution.marked binding key</span>

```Message```

```json=
    {
        "solution": {
            "_id": "solutionId",
            "solution_point": 9,
            "teacher_id": "teacherId"
        },
        "event": {
            "_id": "eventId"
        }
    }
```


## List of events that basic-html-css-service consumes

### Register Event

Description: This event is published by register service
> exchange name: <b>auth-ex</b>

>exchange type: <b>fanout</b>

> queue name: <b>exercise-svc-register-event-handler</b>

```Message```

```json=
    {
        "user": {
            "_id": "userId",
            "username": "NGUYEN VAN A",
            "avatar": "http://avatar.com",
            "email": "17128001@student.hcmus.edu.vn",
            "student_code": "17128001"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

### Profile Event

Description: This event is published by profile service
> exchange name: <b>profile-ex</b>

> exchange type: <b>fanout</b>

> queue name: <b>exercise-svc-user-profile-event-handler</b>

```Message```

```json=
    {
        "user": {
            "_id": "userId",
            "username": "NGUYEN VAN A",
            "avatar": "http://avatar.com",
            "student_code": "17128001"
        },
        "event": {
            "_id": "eventId"
        }
    }
```

### Repository Event
Description: This event is published by repository service
> exchange name: <b>pjs-repo-ex</b>

> exchange type: <b>direct</b>

> queue name: <b>pjs-svc-repository-event-handler</b>

> queue binding key: <b>exercise.chosen.list</b>

```Message```

```json=
    {
        "data": {
            "count": 1,
            "course_id": "courseId",
            "user_id": "userId",
            "exercises": [
                {
                    "exercise_name": "BTCN 1 Understand HTML structure",
                    "exercise_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.",
                    "exercise_type": "JS",
                    "exercise_code_html": "<h1></h1>",
                    "exercise_code_css": ".eye { background-color: #fff }",
                }
            ]
        },
        "event": {
            "_id": "eventId"
        }
    }
```


