From 4c7aebc5f4ee67ff15631f0e8679f7b3cf21cafa Mon Sep 17 00:00:00 2001 From: Dung Nguyen Date: Wed, 9 Nov 2022 17:39:50 -0500 Subject: [PATCH 1/5] fix: Prepend HTTP method in m2 --- docs/milestone2.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/milestone2.md b/docs/milestone2.md index 10008d4..fb29e88 100644 --- a/docs/milestone2.md +++ b/docs/milestone2.md @@ -5,49 +5,49 @@ Usage examples for all of these api's are in `src/frontend/js/client.js` ##### server/server.js -> `/comments/create` +> `POST comments/create` This api is used to insert a new comment into the server-side db. The web-app uses it to insert notes using the message-field in the leftmost view of index.html. -> `/comments/read` +> `POST /comments/read` This api is used to read all the currently existing notes from the server-side db. It is used to display the notes in the leftmost view of index.html, as well as continuously refresh the comments on the user-facing display. -> `/comments/update` +> `POST /comments/update` This api is used to update existing comments. It reads out a comment from the database, and changes its data field based on the changes requested by the user. -> `/comments/delete` +> `POST /comments/delete` This api is used to delete an existing comment. It takes in a note id and uses it to delete a note from the server-side db. -> `/cfg/function_list` +> `GET /cfg/function_list` This api is used to return a list of function names for the target. This api's usecase basically mirrors just running objdump on the target binary with the option to just look for function nanmes. -> `/cfg/cfg_for_func` +> `POST /cfg/cfg_for_func` This api takes in a function name and queries the targets cfg-object to return the control flow graph for the function corresponding to the name. ##### server/routes/user.js -> `/users` +> `GET /users` This api returns information about all users -> `users/:id` +> `GET /users/:id` This api takes in a user id from the get request to it and uses it to return the data about a -user-account. +user-account. -> `/users/verify` +> `POST /users/verify` This api validates a username/password from the data of a post request and communicates if this is a valid combination for an existing user. -> `/users/register` +> `POST /users/register` This api takes in a username/password from the data of a post request and uses it to register a new user to the server-side db. ##### server/routes/stat.js -> `/stats` +> `GET /stats` This api simply returns an object that contains all the relevant high-level statistics information. ##### server/routes/source.js From 9704854272ac931cf8bb306c97da195c6e48690d Mon Sep 17 00:00:00 2001 From: Dung Nguyen Date: Wed, 9 Nov 2022 18:01:06 -0500 Subject: [PATCH 2/5] fix: m2 format --- docs/milestone2.md | 97 +++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/docs/milestone2.md b/docs/milestone2.md index fb29e88..1abab15 100644 --- a/docs/milestone2.md +++ b/docs/milestone2.md @@ -2,53 +2,96 @@ #### 0. API Documentation -Usage examples for all of these api's are in `src/frontend/js/client.js` +Usage examples for all of these API's are in `src/frontend/js/client.js` ##### server/server.js -> `POST comments/create` -This api is used to insert a new comment into the server-side db. The web-app uses it to insert +> `POST comments/create` +This API is used to insert a new comment into the server-side DB. The web-app uses it to insert notes using the message-field in the leftmost view of index.html. -> `POST /comments/read` -This api is used to read all the currently existing notes from the server-side db. It is used to +Expected body: +```json +{ + "timestamp": "string", + "user": "string", + "msg": "string", + "id": "number" +} +``` + +> `POST /comments/read` +This API is used to read all the currently existing notes from the server-side db. It is used to display the notes in the leftmost view of index.html, as well as continuously refresh the comments on the user-facing display. -> `POST /comments/update` -This api is used to update existing comments. It reads out a comment from the database, and changes +> `POST /comments/update` +This API is used to update existing comments. It reads out a comment from the database, and changes its data field based on the changes requested by the user. +Expected body: +```json +{ + "idToUpdate": "number", + "newText": "string", +} +``` > `POST /comments/delete` -This api is used to delete an existing comment. It takes in a note id and uses it to delete a note +This API is used to delete an existing comment. It takes in a note id and uses it to delete a note from the server-side db. +Expected body: +```json +{ + "idToDelete": "number", +} +``` > `GET /cfg/function_list` -This api is used to return a list of function names for the target. This api's usecase basically +This API is used to return a list of function names for the target. This API's usecase basically mirrors just running objdump on the target binary with the option to just look for function nanmes. > `POST /cfg/cfg_for_func` -This api takes in a function name and queries the targets cfg-object to return the control flow +This API takes in a function name and queries the targets cfg-object to return the control flow graph for the function corresponding to the name. +Expected body: +```json +{ + "func_name": "string", +} +``` ##### server/routes/user.js > `GET /users` -This api returns information about all users +This API returns information about all users > `GET /users/:id` -This api takes in a user id from the get request to it and uses it to return the data about a +This API takes in a user `id` from the get request to it and uses it to return the data about a user-account. > `POST /users/verify` -This api validates a username/password from the data of a post request and communicates if this is +This API validates a username/password from the data of a post request and communicates if this is a valid combination for an existing user. +Expected body: +```json +{ + "username": "string", + "password": "string", +} +``` > `POST /users/register` -This api takes in a username/password from the data of a post request and uses it to register a new +This API takes in a username/password from the data of a post request and uses it to register a new user to the server-side db. +```json +{ + "username": "string", + "password": "string", +} +``` ##### server/routes/stat.js + > `GET /stats` -This api simply returns an object that contains all the relevant high-level statistics information. +This API simply returns an object that contains all the relevant high-level statistics information. ##### server/routes/source.js @@ -61,36 +104,36 @@ exist, 404 returned. #### 2. Front-end Implementation -We have many different apis for different user interfaces of our application. Since this part of the +We have many different APIs for different user interfaces of our application. Since this part of the milestone however only asks for 4 screenshots of very specific functionalities, therefore we will -showcase 4 screenshots for the create/read/update/delete operations for the notes/comments api. +showcase 4 screenshots for the Create/Read/Update/Delete operations for the notes/comments API. -> Create +> _Create_ This screenshot showcases the comments window, and how new comments can be added to it using the text-field and the 'send' button. - ![](../imgs/notes_create.PNG) -> Read -This screenshot just showcases the comments window. The read api is used to read out comments from +> _Read_ +This screenshot just showcases the comments window. The read API is used to read out comments from the server-side db and lists them on the user interface. ![](../imgs/notes_read.PNG) -> Update -This screenshot showcases how the update api can be used to update a comment on the site +> _Update_ +This screenshot showcases how the update API can be used to update a comment on the site ![](../imgs/notes_edit1.PNG) ![](../imgs/notes_edit2.PNG) -> Delete -This screenshot showcases how the delete api can be used to delete a comment on the site +> _Delete_ +This screenshot showcases how the delete API can be used to delete a comment on the site ![notes_delete](../imgs/notes_delete1.PNG) ![notes_delete](../imgs/notes_delete2.PNG) #### 3. Deployment -Our website is currently deployed at boiling-forest-11621.herokuapp.com +Our website is currently deployed at https://boiling-forest-11621.herokuapp.com +Automatic deployment is enabled on main branch. #### Work Breakdown We did almost all of the work on this project together in one room, so we all spent approximately the same amount of time on this project. We were able to split the project up fairly well during -this time with everyone working on different apis. +this time with everyone working on different APIs. From eea74a9b649c7de16ead8a6e8ff0db8670cdc3e6 Mon Sep 17 00:00:00 2001 From: Dung Nguyen Date: Wed, 9 Nov 2022 18:04:10 -0500 Subject: [PATCH 3/5] fix: setup token in FE --- src/frontend/js/dashboard.js | 5 +++++ src/server/database.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/js/dashboard.js b/src/frontend/js/dashboard.js index 9424f23..f2be8ac 100644 --- a/src/frontend/js/dashboard.js +++ b/src/frontend/js/dashboard.js @@ -88,3 +88,8 @@ async function populateStat() { populateUser(); populateStat(); +// Automatically set token +// TODO: Remove this when login is public +if (localStorage.getItem("token") === null) { + localStorage.setItem("token", "SAMPLE_TOKEN"); +} diff --git a/src/server/database.js b/src/server/database.js index 0c4b6ae..f67da67 100644 --- a/src/server/database.js +++ b/src/server/database.js @@ -1,5 +1,6 @@ // Temporary data entries -const authTokens = ["UMASS EXPRESS_BAD"]; +// Express.js could have been better to handle these +const authTokens = ["SAMPLE_TOKEN"]; const userlist = [ { first: "Ronan", From 3be2696ecec13c539a5db1a15c1ea61a2b897621 Mon Sep 17 00:00:00 2001 From: Dung Nguyen Date: Wed, 9 Nov 2022 18:08:12 -0500 Subject: [PATCH 4/5] fix: spacing --- docs/milestone2.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/milestone2.md b/docs/milestone2.md index 1abab15..944489b 100644 --- a/docs/milestone2.md +++ b/docs/milestone2.md @@ -5,10 +5,9 @@ Usage examples for all of these API's are in `src/frontend/js/client.js` ##### server/server.js -> `POST comments/create` +> `POST comments/create` This API is used to insert a new comment into the server-side DB. The web-app uses it to insert -notes using the message-field in the leftmost view of index.html. - +notes using the message-field in the leftmost view of index.html. Expected body: ```json { @@ -19,14 +18,14 @@ Expected body: } ``` -> `POST /comments/read` +> `POST /comments/read` This API is used to read all the currently existing notes from the server-side db. It is used to display the notes in the leftmost view of index.html, as well as continuously refresh the comments on the user-facing display. -> `POST /comments/update` +> `POST /comments/update` This API is used to update existing comments. It reads out a comment from the database, and changes -its data field based on the changes requested by the user. +its data field based on the changes requested by the user. Expected body: ```json { @@ -38,7 +37,7 @@ Expected body: > `POST /comments/delete` This API is used to delete an existing comment. It takes in a note id and uses it to delete a note from the server-side db. -Expected body: +Expected body: ```json { "idToDelete": "number", @@ -51,7 +50,7 @@ mirrors just running objdump on the target binary with the option to just look f > `POST /cfg/cfg_for_func` This API takes in a function name and queries the targets cfg-object to return the control flow -graph for the function corresponding to the name. +graph for the function corresponding to the name. Expected body: ```json { @@ -69,7 +68,7 @@ user-account. > `POST /users/verify` This API validates a username/password from the data of a post request and communicates if this is -a valid combination for an existing user. +a valid combination for an existing user. Expected body: ```json { @@ -80,7 +79,8 @@ Expected body: > `POST /users/register` This API takes in a username/password from the data of a post request and uses it to register a new -user to the server-side db. +user to the server-side db. +Expected body: ```json { "username": "string", @@ -95,10 +95,10 @@ This API simply returns an object that contains all the relevant high-level stat ##### server/routes/source.js -> `GET /sources/list` +> `GET /sources/list` This API acquires available files listed in `project_dir/` in the server. -> `GET /sources/file?path={p}` +> `GET /sources/file?path={p}` This API acquires file with path `p` in `project_dir/`. If the file does not exist, 404 returned. @@ -108,30 +108,31 @@ We have many different APIs for different user interfaces of our application. Si milestone however only asks for 4 screenshots of very specific functionalities, therefore we will showcase 4 screenshots for the Create/Read/Update/Delete operations for the notes/comments API. -> _Create_ +> _Create_ This screenshot showcases the comments window, and how new comments can be added to it using the -text-field and the 'send' button. +text-field and the 'send' button. ![](../imgs/notes_create.PNG) -> _Read_ +> _Read_ This screenshot just showcases the comments window. The read API is used to read out comments from -the server-side db and lists them on the user interface. +the server-side db and lists them on the user interface. ![](../imgs/notes_read.PNG) -> _Update_ -This screenshot showcases how the update API can be used to update a comment on the site +> _Update_ +This screenshot showcases how the update API can be used to update a comment on the site ![](../imgs/notes_edit1.PNG) ![](../imgs/notes_edit2.PNG) -> _Delete_ -This screenshot showcases how the delete API can be used to delete a comment on the site +> _Delete_ +This screenshot showcases how the delete API can be used to delete a comment on the site ![notes_delete](../imgs/notes_delete1.PNG) ![notes_delete](../imgs/notes_delete2.PNG) #### 3. Deployment Our website is currently deployed at https://boiling-forest-11621.herokuapp.com -Automatic deployment is enabled on main branch. + +Automatic deployment is enabled on `main` branch. #### Work Breakdown We did almost all of the work on this project together in one room, so we all spent approximately From 763a2da4b78501e494ec2ca617b3c6c1db8e72a7 Mon Sep 17 00:00:00 2001 From: Dung Nguyen Date: Wed, 9 Nov 2022 18:09:19 -0500 Subject: [PATCH 5/5] fix: wrong deploy link --- docs/milestone2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/milestone2.md b/docs/milestone2.md index 944489b..3f2caff 100644 --- a/docs/milestone2.md +++ b/docs/milestone2.md @@ -130,7 +130,7 @@ This screenshot showcases how the delete API can be used to delete a comment on #### 3. Deployment -Our website is currently deployed at https://boiling-forest-11621.herokuapp.com +Our website is currently deployed at https://boiling-forest-11261.herokuapp.com/ Automatic deployment is enabled on `main` branch.