# Repository Service ## List of events that repository-service publishs ### Basic HTML/CSS/JS Exercise - Publish exercises chosen Description: This event is published list exercise chosen by teacher > exchange name: exercise-ex >exchange type: direct > queue name: exercise-svc-repository-event-handler > key: exercise.chosen.list ```Message``` ```JSON { data: { "courseId": "9a602267-b217-47b9-a931-ab762004e2af", "exercises": { "count": 1, "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_body": "<html><head><title>Bai 1</title></head><body></body></html>", "exercise_code_html": "<h1></h1>", "exercise_code_css": ".eye { background-color: #fff }", "exercise_code_js": "var a = 'token'; console.log(a.length);", } ] } }, "event": { "_id": "eventId" } } ``` ### Pure JS Exercise - Publish exercises chosen Description: This event is published list exercise chosen by teacher > exchange name: pjs-repo-ex >exchange type: direct > queue name: exercise-svc-repository-event-handler > key: exercise.chosen.list ```Message``` ```JSON= { "exercises":[ { "exercise_name":"BTCN 1: Sub 2 number", "exercise_description":"Write a function that returns the sub of two numbers.", "exercise_type":"PURE_JAVASCRIPT", "js_exercise_type":"FUNCTION", "exercise_code_js":"function sub(param1, param2) {\n}", "exercise_testcases":[ { "_id":"afibeifbiebfiebifbefbhe", "testcase_input":[ 1, 3 ], "testcase_output":[ 1 ], "order":1 } ], "exercise_io_datatype":{ "_id":"1a5bff06-8d3b-4623-af13-74fc642a910a", "input":[ "number", "number" ], "output":[ "number" ] } } ], "event":{ "_id":"dbf9ad86-f86e-4ccc-9a83-daeceaa857e1" } } ``` ### Course Service - Publish document chosen Description: This event is published document list chosen by teacher > exchange name: course-repo-ex > exchange type: direct > queue name: course-svc-repository-event-handler > key: document.chosen.list ```Message``` ```JSON { "data": { "count": 1, "course_id": "courseId", "user_id": "userId", "documents": [ { "document_name":"Basic HTML", "document_description":"Tài liệu cơ bản về HTML", "document_type":"UPLOAD", "document_path":"1624172254561.pdf", "document_subject":"HTML" } ] }, "event": { "_id": "eventId" } } ``` ## List of events that repository-service consumes ### Register Event Description: This event is published by register service > exchange name: auth-ex >exchange type: fanout > queue name: repository-svc-register-event-handler ```Message``` ```JSON { "user": { "_id": "userId", "email": "someone@gmail.com", "avatar": "http://avatar.com", "username": "John smith", "password": "passwordHash", "provider": "google", "google_id": "googleId", "microsoft_id": "microsoftId", "is_verified": true, "role": "STUDENT", "student_code": "1712810" }, "event": { "_id": "eventId" } } ``` ### Profile Event Description: This event is published by profile service > exchange name: profile-ex >exchange type: fanout > queue name: repository-svc-user-profile-event-handler ```Message``` ```JSON { "user": { "_id": "userId", "username": "NGUYEN VAN A", "avatar": "http://avatar.com", "student_code": "17128001" }, "event": { "_id": "eventId" } } ``` ### Basic HTML/CSS/JS Exercise - Saving to Public Repository Event Description: This event is published by basic html/css/js service when user want to save exercise to PUBLIC repository > exchange name: repository-ex >exchange type: direct > queue name: repository-svc-exercise-event-handler > key: exercise.public.save ```Message``` ```JSON { "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 }", "exercise_code_js": "var a = 'token'; console.log(a.length);", "user_id": "7092eebd-7ceb-4ab1-b7c0-4f2066de2435" } ], "event": { "_id": "eventId" } } ``` ### Basic HTML/CSS/JS Exercise - Saving to Private Repository Event Description: This event is published by basic html/css/js service when user want to save exercise to PRIVATE repository > exchange name: repository-ex >exchange type: direct > queue name: repository-svc-exercise-event-handler > key: exercise.private.save ```Message``` ```JSON { "exercise": [ { "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 }", "exercise_code_js": "var a = 'token'; console.log(a.length);", "user_id": "7092eebd-7ceb-4ab1-b7c0-4f2066de2435" } ], "event": { "_id": "eventId" } } ``` ### Pure JS Exercise - Saving to Public Repository Event Description: This event is published by pure js service when user want to save exercise to PUBLIC repository > exchange name: repo-pjs-ex >exchange type: direct > queue name: repository-svc-pjs-event-handler > key: exercise.public.save ```Message``` ```JSON= { "exercises":[ { "_id":"3bacdbbd-d2f0-43bd-9b26-0f8b4efe3118", "exercise_name":"BTCN 1: Sub 2 number", "exercise_description":"Write a function that returns the sub of two numbers.", "exercise_type":"PURE_JAVASCRIPT", "js_exercise_type":"FUNCTION", "exercise_code_js":"function sub(param1, param2) {\n}", "created_by":{ "_id":"7092eebd-7ceb-4ab1-b7c0-4f2066de2435", "full_name":"NGUYỄN NGỌC TÍN", "email":"teacher.test@fit.hcmus.edu.vn" }, "exercise_testcases":[ { "_id":"afibeifbiebfiebifbefbhe", "testcase_input":[ 1, 3 ], "testcase_output":[ 1 ], "order":1 } ], "exercise_io_datatype":{ "_id":"1a5bff06-8d3b-4623-af13-74fc642a910a", "input":[ "number", "number" ], "output":[ "number" ] } } ], "event":{ "_id":"dbf9ad86-f86e-4ccc-9a83-daeceaa857e1" } } ``` ### Pure JS Exercise - Saving to Private Repository Event Description: This event is published by pure js service when user want to save exercise to PRIVATE repository > exchange name: repo-pjs-ex >exchange type: direct > queue name: repository-svc-pjs-event-handler > key: exercise.public.save > key: exercise.private.save ```Message``` ```JSON= { "exercises":[ { "_id":"3bacdbbd-d2f0-43bd-9b26-0f8b4efe3118", "exercise_name":"BTCN 1: Sub 2 number", "exercise_description":"Write a function that returns the sub of two numbers.", "exercise_type":"PURE_JAVASCRIPT", "js_exercise_type":"FUNCTION", "exercise_code_js":"function sub(param1, param2) {\n}", "created_by":{ "_id":"7092eebd-7ceb-4ab1-b7c0-4f2066de2435", "full_name":"NGUYỄN NGỌC TÍN", "email":"teacher.test@fit.hcmus.edu.vn" }, "exercise_testcases":[ { "_id":"afibeifbiebfiebifbefbhe", "testcase_input":[ 1, 3 ], "testcase_output":[ 1 ], "order":1 } ], "exercise_io_datatype":{ "_id":"1a5bff06-8d3b-4623-af13-74fc642a910a", "input":[ "number", "number" ], "output":[ "number" ] } } ], "event":{ "_id":"dbf9ad86-f86e-4ccc-9a83-daeceaa857e1" } } ``` ### Course Exercise - Saving Document to Public Repository Event Description: This event is published by course service when teacher want to save document to PUBLIC repository > exchange name: repo-course-ex >exchange type: direct > queue name: repository-svc-course-event-handler > key: document.public.save ```Message``` ```JSON { "document": { "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": "UPLOAD", "document_subject": "HTML", "document_path": "src/app/public/documents/blbla.pdf", "created_by": "7092eebd-7ceb-4ab1-b7c0-4f2066de2435" }, "event": { "_id": "eventId" } } ``` ### Course Exercise - Saving Document to Private Repository Event Description: This event is published by course service when teacher wants to save document to PRIVATE repository > exchange name: repo-course-ex >exchange type: direct > queue name: repository-svc-course-event-handler > key: document.private.save ```Message``` ```JSON { "document": { "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", "created_by": "7092eebd-7ceb-4ab1-b7c0-4f2066de2435" }, "event": { "_id": "eventId" } } ``` ### Course Exercise - Delete Document Resource Event Description: This event is published by course service when teacher remove document. > exchange name: repo-course-ex >exchange type: direct > queue name: repository-svc-course-event-handler > key: document.delete.resrc ```Message``` ```JSON { "document": { "document_path": "1621845362829.pdf", }, "event": { "_id": "eventId" } } ```