-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fill level change api #8
base: main
Are you sure you want to change the base?
Conversation
src/app.ts
Outdated
@@ -53,7 +57,7 @@ initializeMQTT(globalEventEmitter); | |||
|
|||
// Middleware | |||
app.use(bodyParser.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the new middleware, that you added, we dont need this line anymore, right? How about moving line 25 and 26 to here and removing the bodyparser.json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks better now, nice :)
But line 25 and 59 are now duplicate, right? So perhaps remove line 25?
ok, all in all this looks really good now :) |
…pdate new value in trashbin fill level change value.
src/mqttClient.ts
Outdated
@@ -98,6 +99,9 @@ export function initializeMQTT(eventEmitter: EventEmitter) { | |||
trashbin[0].fillLevel = fillLevel ? Math.round(fillLevel * 100) : 0; | |||
await trashbin[0].save(); | |||
} | |||
await axios.put('http://localhost:5001/api/v1/trashbin/updateFillLevelChanges', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely an interesting idea to use axios to call the url of the backend.
Latency wise this is not an optimal solution and it also creates unnecessary overhead.
Please have a look at the src/service
folder. For example there is already a function called "generateUniqueTrashbinIdentifier" implemented there. This function can then be imported and used in other places of the backend.
Please refactor your code to also use this service structure to update fillLevelChanges and then import the defined function in the mqtt and trashbin controller file (and dont forget to remove axios from the dependencies in the package.json).
Perhaps you could even make it so, that when a new measurement comes in, not all fillLevelChanges are updated but just the one of the corresponding trashbin (atleast I think, that currently all levelChanges are updated, but perhaps Im misunderstanding).
…rashcan-backend into fill-Level-Change-Api
No description provided.