Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
11e12b4
Setting up GitHub Classroom Feedback
github-classroom[bot] Aug 26, 2022
15e72a9
npm install
ChengJiyuqing Aug 26, 2022
5a114a9
fixed mongodb
ChengJiyuqing Aug 26, 2022
2fc3e8c
npm install in frontend directory
ChengJiyuqing Aug 26, 2022
2b9c10a
fixed error of 'React' must be in scope when using JSX
ChengJiyuqing Aug 26, 2022
057c3e8
added git ignore, removed frontend/node_modules
ChengJiyuqing Aug 28, 2022
991274f
Files from installing dependencies for user service
tanyutao544 Aug 28, 2022
aece683
Simple Login UI added
ChengJiyuqing Aug 29, 2022
79e27a6
implemented Login UI and simple login backend
ChengJiyuqing Aug 29, 2022
dafd06f
npm install and add gitignore
joszx Aug 31, 2022
2c80bb5
add socket.io server instance for matching service
joszx Sep 1, 2022
ea9065f
Squashed commit:
tanyutao544 Aug 28, 2022
cd49e2c
improved routing of login and added validation
ChengJiyuqing Aug 31, 2022
ca9594c
Merge pull request #16 from CS3219-AY2223S1/FR1.2
tanyutao544 Sep 4, 2022
39dfa66
Merge branch 'main' into Chloe
ChengJiyuqing Sep 5, 2022
08e8664
".gitignore" file: update file.
lchokhoe Sep 7, 2022
ba4417b
"MatchingPage.js" file: created file in "components" directory.
lchokhoe Sep 7, 2022
8d085f2
Merge remote-tracking branch 'cs3219-project-ay2223s1-g48/Chloe' into…
lchokhoe Sep 7, 2022
375e0e2
Dummy commit to be squashed
lchokhoe Sep 7, 2022
566b99e
Changes to frontend/package-lock.json
lchokhoe Sep 7, 2022
d05a866
Expose routes to delete and patch User
tanyutao544 Sep 8, 2022
409f18d
set up repository.js
joszx Sep 10, 2022
2528780
add ORM layer to create new match
joszx Sep 10, 2022
fa08738
add event listener in socket.io socket controller to create new match
joszx Sep 10, 2022
227ebe1
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
joszx Sep 10, 2022
af9f146
Create new methods for repo, user-orms layer
tanyutao544 Sep 12, 2022
7eb64e9
Merge pull request #17 from lchokhoe/10-fr-2.1
joszx Sep 12, 2022
a3db18c
Merge pull request #19 from CS3219-AY2223S1/FR1.3-6
ChengJiyuqing Sep 13, 2022
7cdf1b6
FR1.3
ChengJiyuqing Aug 26, 2022
cbd40cc
Implemented Hash and Salt for passwords
ChengJiyuqing Sep 8, 2022
c5306ac
Merge pull request #18 from CS3219-AY2223S1/Chloe
ChengJiyuqing Sep 13, 2022
77c28ca
Add logic to match users
joszx Sep 17, 2022
dcccd2a
Merge branch 'FR2.2' of https://github.com/CS3219-AY2223S1/cs3219-pro…
lchokhoe Sep 17, 2022
f4f5a1e
Add difficulty matching
joszx Sep 18, 2022
3a1bd7c
Improve separation of concerns of match model, orm and repository
joszx Sep 18, 2022
32d8cff
Add match fail event
joszx Sep 19, 2022
c6799f9
Merge branch 'main' into FR2.2
joszx Sep 20, 2022
f9d5a98
Testing code to be squashed
lchokhoe Sep 20, 2022
af353a5
Merge branch 'FR2.2' of https://github.com/CS3219-AY2223S1/cs3219-pro…
lchokhoe Sep 20, 2022
eeadbba
Fix wrong socket id variable
joszx Sep 20, 2022
a18fb53
Fix socket emit to own socket id
joszx Sep 20, 2022
a83fa50
Commit to be squashed.
lchokhoe Sep 20, 2022
36600fc
Merge branch 'FR2.2' of https://github.com/CS3219-AY2223S1/cs3219-pro…
lchokhoe Sep 20, 2022
e288884
Merge pull request #20 from CS3219-AY2223S1/FR2.2
lchokhoe Sep 20, 2022
c1d1959
Commit to be squashed.
lchokhoe Sep 20, 2022
895ab48
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
lchokhoe Sep 20, 2022
5be337d
"MatchingPage.js" file: updated file.
lchokhoe Sep 20, 2022
eef719f
Merge branch '11&12-fr-2.2&2.3' of https://github.com/lchokhoe/cs3219…
lchokhoe Sep 20, 2022
92618cd
Merge pull request #21 from CS3219-AY2223S1/FR-2.3,-2.4-&-2.4-(Frontend)
joszx Sep 20, 2022
f748c8e
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
lchokhoe Sep 21, 2022
57f8279
"MatchingPage.js" file: updated file.
lchokhoe Sep 21, 2022
e927bd2
Merge pull request #22 from CS3219-AY2223S1/14-fr-2.5
joszx Sep 21, 2022
852f918
Added authorisation, fixed matching page margin
ChengJiyuqing Sep 30, 2022
a2a0fcd
Merge pull request #23 from CS3219-AY2223S1/Authorization
joszx Sep 30, 2022
861376b
Add question service
tanyutao544 Oct 5, 2022
5d9e670
update gitignore for new question service
tanyutao544 Oct 5, 2022
f34f314
Update Navbar.js
lchokhoe Oct 5, 2022
9ea4ebb
Update MatchingPage.js
lchokhoe Oct 5, 2022
5d37296
Update MatchingPage.js and MatchingRoom.js
lchokhoe Oct 5, 2022
11292bd
Update MatchingRoom.js and index.css
lchokhoe Oct 5, 2022
143388e
Update MatchingRoom.js and index.css
lchokhoe Oct 5, 2022
181638f
Update MatchingRoom.js and index.css
lchokhoe Oct 5, 2022
f43b0df
Merge pull request #24 from CS3219-AY2223S1/Question-service
lchokhoe Oct 5, 2022
2c7a91c
Merge branch 'main' into Bug-fixes-25-26-27-FR-28
lchokhoe Oct 5, 2022
89844f8
Merge pull request #29 from CS3219-AY2223S1/Bug-fixes-25-26-27-FR-28
joszx Oct 6, 2022
b417fb6
Update MatchingRoom.js
lchokhoe Oct 6, 2022
fe73e53
Update MatchingRoom.js
lchokhoe Oct 6, 2022
8ee4dfe
Created communication-service directory.
lchokhoe Oct 6, 2022
197cfbb
Update to communication-service directory
lchokhoe Oct 6, 2022
81c3409
Update to communication-service directory
lchokhoe Oct 6, 2022
2697e06
Update index.css
lchokhoe Oct 6, 2022
8d42c1b
Update MatchingRoom.js
lchokhoe Oct 6, 2022
e033ac6
Update index.js and MatchingRoom.js
lchokhoe Oct 6, 2022
2cff52d
1. Added an AppError component which gets used if any of the
lchokhoe Oct 7, 2022
fcb3435
Fixed a bug where duplicate messages are not sent properly.
lchokhoe Oct 7, 2022
d97d6aa
Start page, Login page and Sign up page
ChengJiyuqing Oct 6, 2022
e7c8cec
Add yjs collaborative code editor
joszx Oct 15, 2022
832b31d
Merge remote-tracking branch 'cs3219-project-ay2223s1-g48/UI-Improvem…
lchokhoe Oct 15, 2022
ef983a2
Add cursor styling information for codemirror user awareness
joszx Oct 15, 2022
db38a48
modify get with new route
tanyutao544 Oct 15, 2022
f33923a
update with new API to get all questions
tanyutao544 Oct 15, 2022
593be21
update api to allow for update and viewing of question,
tanyutao544 Oct 15, 2022
f637b28
Merge branch 'Question-service-V2' of https://github.com/CS3219-AY222…
lchokhoe Oct 17, 2022
d43c114
Create front end component frames
tanyutao544 Oct 17, 2022
912262a
update qn frontend and backend api patch
tanyutao544 Oct 17, 2022
63f8f26
Complete frontend components for create question
tanyutao544 Oct 18, 2022
6a044f1
Merge pull request #30 from CS3219-AY2223S1/Question-service-V2
lchokhoe Oct 19, 2022
3b838d2
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
lchokhoe Oct 19, 2022
5c17ecb
Update index.js in matching-service directory.
lchokhoe Oct 19, 2022
298a53c
Update package-lock.json in the question-service directory.
lchokhoe Oct 19, 2022
2432aca
Update MatchingPage.js in the frontend directory.
lchokhoe Oct 19, 2022
b3f421e
Update MatchingRoom.js in the frontend directory.
lchokhoe Oct 19, 2022
6d6d5a0
Add drop down to change syntax highlighting for 3 languages
joszx Oct 20, 2022
a021f5f
Move y-webrtc room prefix and pass to .env
joszx Oct 20, 2022
54f3fd6
Changes to frontend/package-lock.json
lchokhoe Oct 21, 2022
cd9ccf0
Merge pull request #31 from CS3219-AY2223S1/communication-service
joszx Oct 21, 2022
d1f1891
Changes
lchokhoe Oct 21, 2022
6523067
Merge branch 'main' into communication-service
lchokhoe Oct 21, 2022
648aa07
Merge branch 'main' into yjs-branch
joszx Oct 21, 2022
1b5179b
Changes:
lchokhoe Oct 21, 2022
2633c9f
Merge pull request #32 from CS3219-AY2223S1/yjs-branch
lchokhoe Oct 21, 2022
0b3bba4
Merge remote-tracking branch 'cs3219-project-ay2223s1-g48/main' into …
lchokhoe Oct 21, 2022
2b8d625
Changes to package-lock.json and frontend/package-lock.json after
lchokhoe Oct 21, 2022
2a9d4e9
Move delete button to update page, Add navigation after update,
tanyutao544 Oct 21, 2022
2df637e
Merge pull request #33 from CS3219-AY2223S1/communication-service
joszx Oct 21, 2022
f8f9bcc
Fix bug for user disconnect while matching
joszx Oct 21, 2022
e2451b3
Merge pull request #34 from CS3219-AY2223S1/question-service-V3
tanyutao544 Oct 24, 2022
06a4edb
Modify user Schema to require email
tanyutao544 Oct 24, 2022
a0c44e7
Merge pull request #35 from CS3219-AY2223S1/User-service-email
tanyutao544 Oct 24, 2022
508fa85
bugfix for update and patch user password after bcrypt implementation
tanyutao544 Oct 25, 2022
7b8a949
Merge pull request #36 from CS3219-AY2223S1/User-service-bugfix
ChengJiyuqing Oct 25, 2022
869a30a
Matching Page nav
ChengJiyuqing Oct 20, 2022
f743790
matching page done + matching room navbar
ChengJiyuqing Oct 21, 2022
93f3181
matching room basic styling
ChengJiyuqing Oct 21, 2022
dbd7621
improved details
ChengJiyuqing Oct 24, 2022
3197e52
hooked delete account and change password
ChengJiyuqing Oct 24, 2022
154cc87
delete and change password success case passed
ChengJiyuqing Oct 25, 2022
a3f5ba7
regression fix
ChengJiyuqing Oct 25, 2022
b0afaca
implements regex for checking email format, clean up code from
tanyutao544 Oct 25, 2022
17c995c
Merge pull request #38 from CS3219-AY2223S1/User-service-regexfix
lchokhoe Oct 27, 2022
7710876
Merge branch 'main' into UI-Improvement
lchokhoe Oct 27, 2022
87c2dd2
Merge pull request #37 from CS3219-AY2223S1/UI-Improvement
lchokhoe Oct 27, 2022
38b6fe1
Merge branch 'main' into matching-bugfix
joszx Oct 28, 2022
75d9731
Merge pull request #39 from CS3219-AY2223S1/matching-bugfix
lchokhoe Oct 28, 2022
b42dddc
Update to dockerize peerprep
lchokhoe Oct 28, 2022
be5e3a8
Merge branch 'main' into dockerize-peerprep
lchokhoe Oct 28, 2022
56098e1
Merge pull request #40 from CS3219-AY2223S1/dockerize-peerprep
tanyutao544 Oct 28, 2022
7234006
github action for user-service deployment
tanyutao544 Oct 28, 2022
5d21cec
change branches
tanyutao544 Oct 28, 2022
6becab0
shift yml file to workflow folder
tanyutao544 Oct 28, 2022
33b4a86
remove .keep file
tanyutao544 Oct 28, 2022
09a41fc
fix syntax for yml file on line 16
tanyutao544 Oct 28, 2022
b8ad3b3
Allow dynamic PORT assignment
tanyutao544 Oct 28, 2022
45bc7ee
add deployment for question service
tanyutao544 Oct 28, 2022
e21c69c
add deployment for matching service
tanyutao544 Oct 28, 2022
15e4777
allow dynamic PORT and change config to point to deployed url
tanyutao544 Oct 28, 2022
d5cdd8b
add deployment for frontend
tanyutao544 Oct 29, 2022
c362476
add engine for node and npm in frontend package
tanyutao544 Oct 29, 2022
2cb915a
change frontend deployment to not use docker
tanyutao544 Oct 29, 2022
a830449
add serve dependency
tanyutao544 Oct 29, 2022
b223eca
specify directory for frontend deployment
tanyutao544 Oct 29, 2022
23480f4
change ref in config
tanyutao544 Oct 29, 2022
d26af12
matching service deploy pls
tanyutao544 Oct 29, 2022
7c18f45
star
tanyutao544 Oct 29, 2022
e5a2c99
remove slash
tanyutao544 Oct 29, 2022
900b35b
add deployment for communication service
tanyutao544 Oct 29, 2022
f523256
new name
tanyutao544 Oct 29, 2022
8428a45
expose port for comm service
tanyutao544 Oct 29, 2022
0557504
change to editor component
tanyutao544 Oct 29, 2022
1311e80
Change yjs to use websocket instead of webRTC
joszx Oct 30, 2022
760eb54
change editor to use deploy collab svc test
tanyutao544 Oct 30, 2022
ed9cf7b
include y-websocket dependency
tanyutao544 Oct 30, 2022
ff9ffcf
remove duplicate import
tanyutao544 Oct 30, 2022
cb9bc23
remove port at end of url for editor.js
tanyutao544 Oct 30, 2022
3fd9263
change prefix name
tanyutao544 Oct 30, 2022
47f0557
Add node script
joszx Oct 30, 2022
fccf444
Remove hostname (+1 squashed commits)
joszx Oct 30, 2022
f23446d
Merge branch 'yjs-branch' of https://github.com/CS3219-AY2223S1/cs321…
lchokhoe Oct 30, 2022
9573d37
Added Dockerfile for collab-service.
lchokhoe Oct 30, 2022
c0ab369
merge collab-service
tanyutao544 Oct 30, 2022
6a96c25
add actions to deploy collab
tanyutao544 Oct 30, 2022
67f37eb
allow actions for deployment branch
tanyutao544 Oct 30, 2022
d1116f7
change editor to ref new deployed collab service
tanyutao544 Oct 30, 2022
6f710b4
Merge pull request #42 from CS3219-AY2223S1/deployment
joszx Nov 4, 2022
4fb1972
frontend minor bug-fix
ChengJiyuqing Oct 28, 2022
42987c4
question page styling
ChengJiyuqing Oct 28, 2022
b87a7a5
question page
ChengJiyuqing Nov 1, 2022
45ba026
in page add question and in page modify question
ChengJiyuqing Nov 1, 2022
996b355
finished styling question page
ChengJiyuqing Nov 3, 2022
d1fc8fc
Merge pull request #41 from CS3219-AY2223S1/UI-Improvement
ChengJiyuqing Nov 6, 2022
438cd77
Fix matching bug
joszx Nov 7, 2022
7c22ce3
Fix question bug for dialog pop up
joszx Nov 7, 2022
0ddf676
Merge pull request #43 from CS3219-AY2223S1/bug-fixing
lchokhoe Nov 7, 2022
33542db
Fix bug frontend question list showing High Medium Low
joszx Nov 8, 2022
accd6b1
Fix bug question frontend consistent capitalization of buttons
joszx Nov 8, 2022
4a987b3
Merge pull request #44 from CS3219-AY2223S1/bug-fixing
tanyutao544 Nov 8, 2022
519c782
Bug fix Low/Med/High to easy/medium/hard
joszx Nov 9, 2022
6fac940
Bug fix question list page for difficulty
joszx Nov 9, 2022
b4a7678
Merge pull request #45 from CS3219-AY2223S1/bug-fixing
tanyutao544 Nov 9, 2022
df0f6bd
Fix bug for creating hard question default value
joszx Nov 9, 2022
e4ce4b2
Add report to documentation
joszx Nov 9, 2022
74dc818
Modify README and add images to documentation
joszx Nov 9, 2022
3b25e8a
Merge pull request #46 from CS3219-AY2223S1/bug-fixing
tanyutao544 Nov 9, 2022
0ce8a3c
Add instructions to README
joszx Nov 9, 2022
f35b3af
Modify README and add note
joszx Nov 9, 2022
f847012
Merge pull request #47 from CS3219-AY2223S1/bug-fixing
lchokhoe Nov 9, 2022
c7c4f14
Update README.md
lchokhoe Nov 9, 2022
8aea9dc
bug fix
ChengJiyuqing Nov 9, 2022
b436694
Update SignupPage.js
ChengJiyuqing Nov 9, 2022
01f3b30
Update SignupPage.js
ChengJiyuqing Nov 9, 2022
4d64db0
Update user-orm.js
tanyutao544 Nov 9, 2022
135f400
Update SignupPage.js
ChengJiyuqing Nov 9, 2022
fce38b6
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
ChengJiyuqing Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
Empty file removed .github/.keep
Empty file.
92 changes: 92 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CD

on:
push:
branches:
- main
- 'deployment'

pull_request:
branches:
- main

jobs:
build-user-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: 'cs3219-48-user-service' #Must be unique in Heroku
heroku_email: '[email protected]'
usedocker: true
appdir: 'user-service'

build-question-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: 'cs3219-48-question-service' #Must be unique in Heroku
heroku_email: '[email protected]'
usedocker: true
appdir: 'question-service'

build-matching-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: 'cs3219-48-matching-service' #Must be unique in Heroku
heroku_email: '[email protected]'
usedocker: true
appdir: 'matching-service'

build-communication-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY2}}
heroku_app_name: 'cs3219-48-communicationservice' #Must be unique in Heroku
heroku_email: '[email protected]'
usedocker: true
appdir: 'communication-service'

build-collab-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected] # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY2}}
heroku_app_name: 'cs3219-48-collab-service' #Must be unique in Heroku
heroku_email: '[email protected]'
usedocker: true
appdir: 'collab-service'

build-frontend-service:
runs-on: ubuntu-latest

steps:
- name: Development Code
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm install
- run: npm run build --if-present
- name: Deploy to Heroku
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY2 }}
heroku_app_name: 'cs3219-48-peerprep'
heroku_email: '[email protected]'
appdir: 'frontend'
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules/
frontend/node_modules/
frontend/.env
user-service/node_modules/
user-service/.env
question-service/.env
question-service/node_modules
communication-service/node_modules
matching-service/node_modules/

76 changes: 65 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,68 @@
# CS3219-AY22-23-Project-Skeleton
# CS3219-AY22-23-Project - PeerPrep (Team 48)

This is a template repository for CS3219 project.
App is deployed at https://cs3219-48-peerprep.herokuapp.com/.

## User Service
1. Rename `.env.sample` file to `.env`.
2. Create a Cloud DB URL using Mongo Atlas.
3. Enter the DB URL created as `DB_CLOUD_URI` in `.env` file.
4. Install npm packages using `npm i`.
5. Run User Service using `npm run dev`.
## Introduction

## Frontend
1. Install npm packages using `npm i`.
2. Run Frontend using `npm start`.
PeerPrep is a web application that helps students prepare for whiteboard style technical interviews. PeerPrep provides a peer learning platform where students can match up with peers depending on difficulty in order to practice technical interview questions. Peerprep comes with a collaborative editor, chatbox as well as a question bank that users can access to see all the available questions.

## How to use Peerprep?

### Prerequisite

Due to the limitation of heroku free tier, please spin up the respective servers before accessing the app on the following link:
https://cs3219-48-peerprep.herokuapp.com/ <br/>
Frontend should show the landing page as per instructions below.

https://cs3219-48-user-service.herokuapp.com/api/user <br/>
User service should display “Hello World from user-service” if successfully loaded.

https://cs3219-48-question-service.herokuapp.com/api/question <br/>
Question service should display a JSON object with “data” as the first field.

https://cs3219-48-matching-service.herokuapp.com/ <br/>
Matching service should display “Hello World from matching-service” when successfully loaded.

https://cs3219-48-collab-service.herokuapp.com/ <br/>
Collab service should display “okay” when successfully loaded.

https://cs3219-48-communicationservice.herokuapp.com/ <br/>
Communication service should display “Hello World from communication-service” if successfully loaded.

<b>Note: </b> You might need to refresh the page if heroku displays an error the first time.

### Instructions

1. From the landing page, click on "Start Coding".
![LandingPage](./documentation/images/LandingPage.jpg)

2. On the login page, if you do not have an account, click on “Create new account”.
![LoginPage](./documentation/images/2.JPG)

3. You will be brought to the register page. Enter the username, password and email that you would like to use, then click “Sign up”.
![RegisterPage](./documentation/images/2.5.JPG)

4. You should see a pop up stating a successful creation. If not, refresh the page and try again. Click “log in”. This will redirect you back to the login page.
![RegisterSuccessPage](./documentation/images/3.JPG)

5. Enter your username and password and click the “Log in” button.
![LoginWithDetailsPage](./documentation/images/4.JPG)

6. Once you are in, you should see the following matching page. Feel free to explore the various buttons but for now let’s go through how to queue for a match.
![MatchingPage](./documentation/images/5.JPG)

7. Select a difficulty. Here we selected “hard”. Then click the “Start Coding” button.
![MatchingPageWithDifficulty](./documentation/images/6.JPG)

8. The match will start and a countdown from the 30s will begin. If you have a friend, get him to queue up as well for the “hard”.
![MatchingTimer](./documentation/images/7.JPG)

9. Now you have successfully matched with your friend and can begin your interview preparation. The editor box on the side allows for you and your friend to code in a collaborative manner.
![MatchingTimer](./documentation/images/8.JPG)

10. However, if after 30s you still have yet to be matched you will be presented with 2 choices. EIther change the difficulty you are queueing for or queue again.
![MatchingTimer](./documentation/images/9.JPG)

### Find out more?

Read our documentation [here](./documentation/48-FinalReport.pdf)!
1 change: 1 addition & 0 deletions collab-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
12 changes: 12 additions & 0 deletions collab-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:16
ENV NODE_ENV=production
RUN apt-get clean && apt-get -y update && apt-get install -y locales && locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US.UTF-8' LC_ALL='en_US.UTF-8'
ENV DIRPATH=/path
WORKDIR $DIRPATH/$DIRNAME
COPY package*.json ./
RUN npm install -g [email protected]
RUN npm install
COPY . .
EXPOSE 1234
CMD [ "npm", "run", "start" ]
86 changes: 86 additions & 0 deletions collab-service/callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const http = require('http');

const CALLBACK_URL = process.env.CALLBACK_URL
? new URL(process.env.CALLBACK_URL)
: null;
const CALLBACK_TIMEOUT = process.env.CALLBACK_TIMEOUT || 5000;
const CALLBACK_OBJECTS = process.env.CALLBACK_OBJECTS
? JSON.parse(process.env.CALLBACK_OBJECTS)
: {};

exports.isCallbackSet = !!CALLBACK_URL;

/**
* @param {Uint8Array} update
* @param {any} origin
* @param {WSSharedDoc} doc
*/
exports.callbackHandler = (update, origin, doc) => {
const room = doc.name;
const dataToSend = {
room,
data: {},
};
const sharedObjectList = Object.keys(CALLBACK_OBJECTS);
sharedObjectList.forEach((sharedObjectName) => {
const sharedObjectType = CALLBACK_OBJECTS[sharedObjectName];
dataToSend.data[sharedObjectName] = {
type: sharedObjectType,
content: getContent(sharedObjectName, sharedObjectType, doc).toJSON(),
};
});
callbackRequest(CALLBACK_URL, CALLBACK_TIMEOUT, dataToSend);
};

/**
* @param {URL} url
* @param {number} timeout
* @param {Object} data
*/
const callbackRequest = (url, timeout, data) => {
data = JSON.stringify(data);
const options = {
hostname: url.hostname,
port: url.port,
path: url.pathname,
timeout,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
},
};
const req = http.request(options);
req.on('timeout', () => {
console.warn('Callback request timed out.');
req.abort();
});
req.on('error', (e) => {
console.error('Callback request error.', e);
req.abort();
});
req.write(data);
req.end();
};

/**
* @param {string} objName
* @param {string} objType
* @param {WSSharedDoc} doc
*/
const getContent = (objName, objType, doc) => {
switch (objType) {
case 'Array':
return doc.getArray(objName);
case 'Map':
return doc.getMap(objName);
case 'Text':
return doc.getText(objName);
case 'XmlFragment':
return doc.getXmlFragment(objName);
case 'XmlElement':
return doc.getXmlElement(objName);
default:
return {};
}
};
45 changes: 45 additions & 0 deletions collab-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions collab-service/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"scripts": {
"dev": "node server.js",
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"lodash.debounce": "^4.0.8",
"ws": "^8.10.0",
"y-protocols": "^1.0.5",
"yjs": "^13.5.42"
}
}
35 changes: 35 additions & 0 deletions collab-service/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

/**
* @type {any}
*/
const WebSocket = require("ws");
const http = require("http");
const wss = new WebSocket.Server({ noServer: true });
const setupWSConnection = require("./utils.js").setupWSConnection;

// const host = process.env.HOST || "localhost";
const port = process.env.PORT || 1234;

const server = http.createServer((request, response) => {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end("okay");
});

wss.on("connection", setupWSConnection);

server.on("upgrade", (request, socket, head) => {
// You may check auth of request here..
// See https://github.com/websockets/ws#client-authentication
/**
* @param {any} ws
*/
const handleAuth = (ws) => {
wss.emit("connection", ws, request);
};
wss.handleUpgrade(request, socket, head, handleAuth);
});

server.listen(port, () => {
console.log(`running on port ${port}`);
});
Loading