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(ws): add regex path support on platform ws path #13403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RavenColEvol
Copy link

@RavenColEvol RavenColEvol commented Apr 5, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently Websocket Adaptor only takes strict pathname as parameter but common use case like YJS works on random websocket route /ws/:room_id which makes it hard nest js to be used in those scenario. This PR will help fixing that use case.

Issue Number: N/A

What is the new behavior?

Websocket Adaptor path parameter can now take pathregex as input like ws/:room_id and it will allow request url which match that pathregex.

import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';

@WebSocketGateway({
  path: '/ws-path/:room_id',
})
export class WsPathGatewayRegex {
  @SubscribeMessage('push')
  onPush(client, data) {
    return {
      event: 'pop',
      data,
    };
  }
}

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I tried running integration test on my local system with docker up but still there were few failing tests for me. I'm new to mocha ( have use jest ) ws-gateway, rpc integration are failing for me even if I roll back my changes. I ran ws-gateway test cases individually as it was not dependent on any docker container with this command

npx mocha --watch integration/websockets/e2e/ws-gateway.spec.ts

@coveralls
Copy link

Pull Request Test Coverage Report for Build 14d10460-30b3-4248-a732-f5de2208efcf

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.123%

Totals Coverage Status
Change from base Build eacd3e56-4bed-4f5e-9bab-412a10335aab: 0.0%
Covered Lines: 6736
Relevant Lines: 7312

💛 - Coveralls

@RavenColEvol
Copy link
Author

@kamilmysliwiec do you think this PR is a valid use case?

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.

None yet

2 participants