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(websockets): add prefix option for api versioning #10597

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

Conversation

notusertelken
Copy link

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?

Websocket gateway options has only path and no 'prefix'

Issue Number: (#9376)

What is the new behavior?

websocket gateway options now has path and prefix which get joined for the full path. this can be used for api versioning

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Nov 24, 2022

Pull Request Test Coverage Report for Build efd3d236-d3d5-498c-b8d8-1f7f949aa4d5

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 93.409%

Totals Coverage Status
Change from base Build a213a525-4c5b-48ee-9803-b76e72178509: 0.005%
Covered Lines: 6207
Relevant Lines: 6645

💛 - Coveralls

options: TOptions,
) {
const { path = '', prefix = '', ...passthrough } = options;
console.log(options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log(options);

The console.log() should be removed

* Api version acts as prefix to path
* @default undefined
*/
prefix?: string;
Copy link
Member

@micalevisk micalevisk Jan 24, 2023

Choose a reason for hiding this comment

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

since we have prefix and versioning for @Controller(), I found "using prefix for api versioning" a bit strange

Can't we avoid mention that specific use case? 🤔 This leaves room for adding first-class versioning in the future

Copy link
Author

Choose a reason for hiding this comment

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

do you mean leave the description as just "path prefix"?

Copy link
Member

Choose a reason for hiding this comment

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

yep

@@ -27,16 +27,21 @@ describe('@WebSocketGateway', () => {
expect(port).to.be.eql(0);
});

@WebSocketGateway({ namespace: '/' })
@WebSocketGateway({ namespace: '/', path: '/path', prefix: '/prefix' })
Copy link
Member

Choose a reason for hiding this comment

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

can we add another test solely to check if the prefix is being added, instead of replacing this one that has no prefix? so we will test both versions

Copy link
Author

Choose a reason for hiding this comment

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

sounds good

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

4 participants