Skip to content

Conversation

@einnjo
Copy link
Contributor

@einnjo einnjo commented Jul 9, 2020

Exposes fastify server in global and per route websocket handlers via this binding.

Adds tests to ensure this is the case in both kinds of handlers.

Adds a note in README to alert users about fastify request lifecycle expectations and clue them into the exposed server inside han dlers.

The typings for per route handlers seemed to already declare that this was bound to the fastify instance even if in reality that was not the case.

Fixes #66

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

@mcollina
Copy link
Member

Would you mind to update https://github.com/fastify/fastify-websocket/blob/master/test/types/index.test-d.ts to test for this type?

@einnjo
Copy link
Contributor Author

einnjo commented Jul 11, 2020

I gave it a go, but I'm completely new to testing types and not familiar at all with tsd. I verified that the tests failed if I removed the declaration from the types file.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 5868e65 into fastify:master Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose decorated fastify server in websocket handler

2 participants