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

feat: integrate asyncapi-validator to validate incomming messages #53

Merged
merged 11 commits into from
Mar 30, 2021

Conversation

KhudaDad414
Copy link
Member

@KhudaDad414 KhudaDad414 commented Mar 26, 2021

Description

  • integrates asyncapi-validator into this template.

Related issue(s)
Resolves #8

@KhudaDad414
Copy link
Member Author

@derberg I've taken a totally different approach here. what do you think?

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

Looks great mate 🚀
I only have few improvements and fix request but from the concept point of view -> well done

@WaleedAshraf wanna have a look?

@reselbob you asked me about this one a week ago, so I guess you'll be happy it is almost there. Feel free to suggest if you would expect something more. Can be done here or in a separate Pr, depending on complexity

package.json Outdated Show resolved Hide resolved
template/src/lib/message-validator.js Show resolved Hide resolved
template/src/lib/message-validator.js Outdated Show resolved Hide resolved
template/src/lib/message-validator.js Outdated Show resolved Hide resolved
@derberg derberg changed the title feat: integrate asyncapi-validator feat: integrate asyncapi-validator to validate incomming messages Mar 26, 2021
@KhudaDad414
Copy link
Member Author

@derberg made the suggested changes.

WaleedAshraf
WaleedAshraf previously approved these changes Mar 27, 2021
Copy link

@WaleedAshraf WaleedAshraf left a comment

Choose a reason for hiding this comment

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

Looks good.

@@ -1,7 +1,11 @@
const { red, gray } = require('colors/safe');

module.exports = (err, message, next) => {
console.error(red(`❗ ${err.message}`));
if (err.stack) console.error(gray(err.stack.substr(err.stack.indexOf('\n')+1)));
if(err.name === 'AsyncAPIValidationError'){

Choose a reason for hiding this comment

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

indent seems broken 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

corrected. (I think)

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

one more thing, sorry but I think it would be super cool to have it in the readme

please change this

#publish your message.
mqtt pub -t 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": 3, "sentAt": "2017-06-07T12:34:32.000Z"}'

# You should see the sent message in the logs of the previously started server.

to something like

#publish an invalid message.
mqtt pub -t 'smartylighting/streetlights/1/0/event/123/lighting/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": "3", "sentAt": "2017-06-07T12:34:32.000Z"}'

#publish a valid message
mqtt pub -t 'smartylighting/streetlights/1/0/event/123/lighting/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": 3, "sentAt": "2017-06-07T12:34:32.000Z"}'

#You should see the sent message in the logs of the previously started server.
#Notice that the server automatically validates incoming messages and logs out validation errors

what do you think?

@derberg
Copy link
Member

derberg commented Mar 29, 2021

@KhudaDad414 I would make code suggestion so you can just commit but unfortunately GH doesn't allow this to lines that were not "touched" by the PR

@KhudaDad414
Copy link
Member Author

@derberg Sorry, I was out of town yesterday. pushed the suggested changes.

@sonarcloud
Copy link

sonarcloud bot commented Mar 30, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

approving with pleasure

@derberg derberg merged commit d7ecd4c into asyncapi:master Mar 30, 2021
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

kaushik-rishi pushed a commit to kaushik-rishi/nodejs-template that referenced this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate asyncapi-validator in Nodejs templates
4 participants