Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LL-317 #92

Merged
merged 15 commits into from
Aug 10, 2024
Merged

LL-317 #92

merged 15 commits into from
Aug 10, 2024

Conversation

KevinLemon112
Copy link
Collaborator

@KevinLemon112 KevinLemon112 commented Jun 20, 2024

Description

In this new PR/Ticket, routes and controllers have been added to the routes and controllers folders via various files for the ActiveMQ notification service. This enables different URL's to lead to different results for the service such as viewing user accounts, creating them, deleting them, etc.

Subsequent # (issue): LL-317

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Steps (For Local Host):

  1. Run Docker Desktop
  2. Make sure you are in the root directory (server)
  3. Run "npm i" if needed (root directory and possibly publish/subscribe directories as well)
  4. Run "docker compose up --build" (You will need the correct .env file. Ask @KevinLemon112 or @pogi7 for it)
  5. Open Postman downloaded app (browser Postman does NOT work for Local Host I believe...)
  6. Input the following routes to test (check MongoDB to confirm changes):

User Routes

Register User

URL: http://localhost:4000/users/register
Method: POST
Body: raw - JSON

JSON (copy and paste this into Postman in the raw - JSON section):

{
"email": "[email protected]",
"name": "John Doe",
"creationDate": "2023-08-28T05:33:57.702Z",
"deletionDate": "2023-08-29T05:33:57.702Z", // Optional, can be omitted if not needed
"lastUpdated": "2023-08-30T05:33:57.702Z",
"devicesLinked": []
}

OR (if you want to test linking a device)

{
"email": "[email protected]",
"name": "John Doe",
"creationDate": "2023-08-28T05:33:57.702Z",
"deletionDate": "2023-08-29T05:33:57.702Z", // Optional, can be omitted if not needed
"lastUpdated": "2023-08-30T05:33:57.702Z",
"devicesLinked": [
{
"uuid": "device1_uuid",
"lastUpdated": "2023-08-28T05:33:57.702Z",
"powered": true, // Optional, can be omitted if not needed
"poweredTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"connected": true, // Optional, can be omitted if not needed
"connectedTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"color": "#FFFFFF", // Optional, can be omitted if not needed
"colorTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"brightness": 50, // Optional, can be omitted if not needed
"brightnessTimestamp": "2023-08-28T05:33:57.702Z" // Optional, can be omitted if not needed
}
]
}


Get All Users

URL: http://localhost:4000/users/all
Method: GET
Get User by ID


Get User by ID

URL: http://localhost:4000/users/:id
Method: GET

(replace ":id" with actual MongoDB account ID)


Delete User by ID

URL: http://localhost:4000/users/:id/delete
Method: DELETE

(replace ":id" with actual MongoDB account ID)


Publish/Subscribe Routes

Publish Message

URL: http://localhost:6000/publish/:id
Method: GET

(replace ":id" with any ID)


Subscribe Status

URL: http://localhost:7000/subscribe/status
Method: GET


Checklist (when relevant):

  • My code follows the style guidelines of this project

TypeScript
Python
Schema

  • I have included a reviewer on the pull request [Replace this text with the reviewer]
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@KevinLemon112 KevinLemon112 added the notification Notification Feature label Jun 20, 2024
@KevinLemon112 KevinLemon112 self-assigned this Jun 20, 2024
@pogi7
Copy link
Collaborator

pogi7 commented Jun 20, 2024

@KevinLemon112 A lot of the work looks good to me. If you want to separate your routes into a single location in the project, I would follow this guide:
https://semaphoreci.com/blog/layer-nodejs

- "1883:1883"
env_file: ".env"

# server:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinLemon112 There was a 404 error in all of the user routes because they were not run on the docker compose server. You will need to either uncomment this service or make a new user service to get the user routes to work.

- "8.8.8.8"
networks:
- backend
publish:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinLemon112 The publish routes weren't working on port 4000, but they work now. You can test by using Postman or a local browser and going to http://localhost:4000/publish/all

You should see something like this:

{
    "id": "all",
    "message": "From Publish Service"
}

Copy link
Collaborator

@erikajledesma erikajledesma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i only had trouble with making a POST request for registering a user with linked devices (returned a 500 error--see attached screenshot). I used the following code to test but everything else lgtm!

image

"email": "[email protected]",
"name": "John Doe",
"creationDate": "2023-08-28T05:33:57.702Z",
"deletionDate": "2023-08-29T05:33:57.702Z", // Optional, can be omitted if not needed
"lastUpdated": "2023-08-30T05:33:57.702Z",
"devicesLinked": [
{
"uuid": "device1_uuid",
"lastUpdated": "2023-08-28T05:33:57.702Z",
"powered": true, // Optional, can be omitted if not needed
"poweredTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"connected": true, // Optional, can be omitted if not needed
"connectedTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"color": "#FFFFFF", // Optional, can be omitted if not needed
"colorTimestamp": "2023-08-28T05:33:57.702Z", // Optional, can be omitted if not needed
"brightness": 50, // Optional, can be omitted if not needed
"brightnessTimestamp": "2023-08-28T05:33:57.702Z" // Optional, can be omitted if not needed
}
]
} 

@erikajledesma
Copy link
Collaborator

erikajledesma commented Jul 29, 2024

@pogi7 Fixed 500 internal server error when making POST request to register user with linked devices

  • change/modify the uuid of the device to avoid triggering 'duplicate key error collection' error
  • set ports 4000, 6000 and 7000 to public visibility when testing

@pogi7 pogi7 self-requested a review August 10, 2024 18:18
Copy link
Collaborator

@pogi7 pogi7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@pogi7 pogi7 merged commit 0c869ef into master Aug 10, 2024
6 of 7 checks passed
@pogi7 pogi7 deleted the LL-317 branch August 10, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notification Notification Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants