-
-
Notifications
You must be signed in to change notification settings - Fork 61
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: add http adapter #265
Conversation
Pull Request Test Coverage Report for Build 2087142664Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
Kudos, SonarCloud Quality Gate passed! |
if (query) { | ||
const {isValid, humanReadableError, errors} = validateData(searchParams, query); | ||
if(!isValid){ | ||
const err = new GleeError({humanReadableError, errors}); | ||
console.log('ERROR', err); | ||
this.emit('error', err); | ||
res.end('HTTP/1.1 400 Bad Request\r\n\r\n'); | ||
return; | ||
} | ||
} | ||
} |
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.
I am trying to validate the query parameters but getting an issue. All the query parameters are being treated as a string so if my query defined in asyncapi.yaml
as a string then whatever the query
is validation results in positive.
bindings:
http:
bindingVersion: 0.1.0
type: request
method: GET
query:
type: object
properties:
name:
type: string
for this ?name=shreak
, ?name
and ?name=12
get validated positively which is something that shouldn't happen.
@fmvilas can you give me some tip on this.
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.
🤔 I think you have to try to find the type on purpose. It's true that query parameters are always treated as strings so you'll only get positives in this case. You can probably do this: try Number(query.name)
and if you don't get NaN
it means it's a number so you can safely do query.name = Number(query.name)
. Same with null
. If you get that query.name
is undefined
or null
then you can safely assign it to null
.
That said, you don't check for query.name
but for each key in the object. Don't forget about array values. Hope that helps :)
Description
Learning the codebase by creating an HTTP adapter.
Aims to -
See also #25