-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add req.ws
#163
Add req.ws
#163
Conversation
Thanks for the PR @a-a-GiTHuB-a-a ! Did you want to work with this one or #162 ? |
Sorry. PR #162 was actually an accident. |
Can you please add a unit test? Also CI is failing |
BRUH WHY IS IT THROWING ERRORS BECAUSE OF FORMAT
index.js
Outdated
@@ -8,7 +8,9 @@ const kWs = Symbol('ws-socket') | |||
const kWsHead = Symbol('ws-head') | |||
|
|||
function fastifyWebsocket (fastify, opts, next) { | |||
let errorHandler = defaultErrorHandler | |||
fastify.decorateRequest('ws', true) |
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.
Just for safety I think it'd make more sense for this to be null by default so that if something changes later with the request hook, it's clear if it has or hasn't been set yet, instead of maybe being a lie (true
), you know?
request.ws = false | ||
} | ||
done() | ||
}) |
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.
Please add a test so future committers don't break this functionality!
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.
What test?
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 it'd make sense to add unit tests that check the value of this property is true for a websocket route and false for a non websocket route.
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.
/@a-a-GiTHuB-a-a are you able to copy one of the existing unit tests to get this in?
CI is failing |
I added more patches to the formatting. |
@a-a-GiTHuB-a-a did you want to update this PR? it'd be a great feature to get in! |
update for PR
I just did, and it makes sense |
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.
lgtm
Maybe?
I removed the trailing spaces. i think. |
I have added a few lines of code to add a
req.ws
boolean for if the request was an upgrade for websocket.