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

Typescript: Allow extending socket's incoming request separately from Express #4795

Open
alesmenzel opened this issue Aug 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@alesmenzel
Copy link

PR here #4787

Is your feature request related to a problem? Please describe.
Use own interface for Socket request to allow extending the request interface with custom properties without polluting the IncomingMessage type which is also used by Express/Passport.

Using socket.io with passport middlewares causes issues when using the same 'userProperty' key is used for both - for example by extending IncomingMessage { user: Express.User } we break passport's isAuthenticated() function, because now typescript thinks that the request is always of the type AuthenticatedRequest as IncomingMessage always has a user property on itself. To fix this, I believe we should be able to extend only the request type inside socket.io -> SocketRequest.

Describe the solution you'd like
Use own interface for Socket request to allow extending the request interface independently of Express.

Describe alternatives you've considered
I haven't found any reasonable workarounds.

Additional context
See #4787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant