-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
refactor(microservices) refactor, improvements, use es6 map #1161
Conversation
Pull Request Test Coverage Report for Build 1317
💛 - Coveralls |
@@ -43,7 +43,7 @@ export class ServerMqtt extends Server implements CustomTransportStrategy { | |||
|
|||
public bindEvents(mqttClient: MqttClient) { | |||
mqttClient.on(MESSAGE_EVENT, this.getMessageHandler(mqttClient).bind(this)); | |||
const registeredPatterns = Object.keys(this.messageHandlers); | |||
const registeredPatterns = [...this.messageHandlers.keys()]; |
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.
It could be simplified using this.messageHandlers.keys()
instead of [...this.messageHandlers.keys()]
👍
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.
Map.keys()
returns an Iterator (not an array)
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.
You're correct! Good catch 😆
@@ -40,7 +40,7 @@ export class ServerNats extends Server implements CustomTransportStrategy { | |||
} | |||
|
|||
public bindEvents(client: Client) { | |||
const registeredPatterns = Object.keys(this.messageHandlers); | |||
const registeredPatterns = [...this.messageHandlers.keys()]; |
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.
And here
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.
as above
@@ -52,7 +52,7 @@ export class ServerRedis extends Server implements CustomTransportStrategy { | |||
|
|||
public bindEvents(subClient: RedisClient, pubClient: RedisClient) { | |||
subClient.on(MESSAGE_EVENT, this.getMessageHandler(pubClient).bind(this)); | |||
const subscribePatterns = Object.keys(this.messageHandlers); | |||
const subscribePatterns = [...this.messageHandlers.keys()]; |
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.
And here
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.
as above
): (data) => Promise<Observable<any>> | null { | ||
return this.messageHandlers[pattern] ? this.messageHandlers[pattern] : null; | ||
public getHandlerByPattern(pattern: string): MessageHandler | null { | ||
return this.messageHandlers.has(pattern) |
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.
It's okey, but it could be shorter if you use this.messageHandlers.get(pattern) || null
:-)
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.
Good!
@@ -80,10 +80,12 @@ describe('ServerGrpc', () => { | |||
|
|||
describe('createService', () => { | |||
it('should call "createServiceMethod"', async () => { | |||
const handlers = { | |||
const objectToMap = obj => |
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.
This function is used in more places (copy/pasted), maybe it could be put in one place and reuse it
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.
Good clean-code
refactor() simplified if (less checks)
feature(common) add validation error factory (ValidationPipe)
feature(common) add async support (HttpModule) and extraProviders
bugfix(ws/microservices): add catchError() to observables
bugfix(common) invalid metadata inheritance with custom providers
bugfix(common): custom exception body #1339
feature(microservices): added option for proto-loader (grpc)
chore() 5.5.0 minor release
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Breaking change due to the different API of custom transport strategies (microservices)