@golevelup/nestjs-rabbitmq
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.3.0](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-rabbitmq@3.2.0...@golevelup/nestjs-rabbitmq@3.3.0) (2022-09-21) | ||
### Bug Fixes | ||
- **rabbitmq:** fix usage of handler config ([#490](https://github.com/golevelup/nestjs/issues/490)) ([241a640](https://github.com/golevelup/nestjs/commit/241a64075e06e15d273994ae786e7d0acec09c31)), closes [#489](https://github.com/golevelup/nestjs/issues/489) | ||
- **rabbitmq:** handle connnection not available issue on RabbitSubscribe and RabbitRPC ([#495](https://github.com/golevelup/nestjs/issues/495)) ([2f2e931](https://github.com/golevelup/nestjs/commit/2f2e93107f14cddac19bac3a7ebda76bf62818ac)) | ||
### Features | ||
- **rabbitmq:** add generic type to publish for simple type checking ([#491](https://github.com/golevelup/nestjs/issues/491)) ([45afeb7](https://github.com/golevelup/nestjs/commit/45afeb7ea8b6cc82ff9ccb64afa65fb59c64744d)) | ||
# [3.2.0](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-rabbitmq@3.1.0...@golevelup/nestjs-rabbitmq@3.2.0) (2022-07-28) | ||
@@ -8,0 +19,0 @@ |
@@ -63,3 +63,3 @@ import { ChannelWrapper, AmqpConnectionManager } from 'amqp-connection-manager'; | ||
setupRpcChannel<T, U>(handler: (msg: T | undefined, rawMessage?: ConsumeMessage, headers?: any) => Promise<RpcResponse<U>>, rpcOptions: MessageHandlerOptions, channel: ConfirmChannel): Promise<ConsumerTag>; | ||
publish(exchange: string, routingKey: string, message: any, options?: Options.Publish): void; | ||
publish<T = any>(exchange: string, routingKey: string, message: T, options?: Options.Publish): void; | ||
private handleMessage; | ||
@@ -66,0 +66,0 @@ private setupQueue; |
@@ -166,5 +166,10 @@ "use strict"; | ||
var _a; | ||
this.selectManagedChannel((_a = msgOptions === null || msgOptions === void 0 ? void 0 : msgOptions.queueOptions) === null || _a === void 0 ? void 0 : _a.channel).addSetup(async (channel) => { | ||
let result; | ||
this.selectManagedChannel((_a = msgOptions === null || msgOptions === void 0 ? void 0 : msgOptions.queueOptions) === null || _a === void 0 ? void 0 : _a.channel) | ||
.addSetup(async (channel) => { | ||
const consumerTag = await this.setupSubscriberChannel(handler, msgOptions, channel, originalHandlerName); | ||
res({ consumerTag }); | ||
result = { consumerTag }; | ||
}) | ||
.then(() => { | ||
res(result); | ||
}); | ||
@@ -171,0 +176,0 @@ }); |
@@ -7,3 +7,4 @@ import { AmqpConnection } from './connection'; | ||
getConnections(): AmqpConnection[]; | ||
clearConnections(): void; | ||
} | ||
//# sourceMappingURL=connectionManager.d.ts.map |
@@ -17,4 +17,7 @@ "use strict"; | ||
} | ||
clearConnections() { | ||
this.connections = []; | ||
} | ||
} | ||
exports.AmqpConnectionManager = AmqpConnectionManager; | ||
//# sourceMappingURL=connectionManager.js.map |
@@ -95,2 +95,4 @@ "use strict"; | ||
.map((connection) => connection.managedConnection.close())); | ||
this.connectionManager.clearConnections(); | ||
RabbitMQModule_1.bootstrapped = false; | ||
} | ||
@@ -128,7 +130,4 @@ // eslint-disable-next-line sonarjs/cognitive-complexity | ||
); | ||
const handlerConfig = connection.configuration.handlers[config.name || '']; | ||
const exchange = (handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.exchange) || config.exchange; | ||
const routingKey = (handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.routingKey) || config.routingKey; | ||
const queue = (handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.queue) || config.queue; | ||
const queueOptions = (handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.queueOptions) || config.queueOptions; | ||
const mergedConfig = Object.assign(Object.assign({}, config), connection.configuration.handlers[config.name || '']); | ||
const { exchange, routingKey, queue, queueOptions } = mergedConfig; | ||
const handlerDisplayName = `${discoveredMethod.parentClass.name}.${discoveredMethod.methodName} {${config.type}} -> ${ | ||
@@ -144,4 +143,4 @@ // eslint-disable-next-line sonarjs/no-nested-template-literals | ||
return config.type === 'rpc' | ||
? connection.createRpc(handler, config) | ||
: connection.createSubscriber(handler, config, discoveredMethod.methodName); | ||
? connection.createRpc(handler, mergedConfig) | ||
: connection.createSubscriber(handler, mergedConfig, discoveredMethod.methodName); | ||
})); | ||
@@ -148,0 +147,0 @@ } |
{ | ||
"name": "@golevelup/nestjs-rabbitmq", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Badass RabbitMQ addons for NestJS", | ||
@@ -64,3 +64,3 @@ "author": "Jesse Carter <jesse.r.carter@gmail.com>", | ||
}, | ||
"gitHead": "3d177addd3e66c25af46dcc6a6d7645565ad4851" | ||
"gitHead": "757012918cb3ce8ddd75a0d2a37fd5fc99ba294d" | ||
} |
@@ -1,2 +0,1 @@ | ||
# @golevelup/nestjs-rabbitmq | ||
@@ -231,3 +230,2 @@ | ||
```typescript | ||
@@ -416,6 +414,6 @@ @RabbitRPC({ | ||
```typescript | ||
public publish( | ||
public publish<T = any>( | ||
exchange: string, | ||
routingKey: string, | ||
message: any, | ||
message: T, | ||
options?: amqplib.Options.Publish | ||
@@ -429,2 +427,10 @@ ) | ||
amqpConnection.publish('some-exchange', 'routing-key', { msg: 'hello world' }); | ||
// optionally specify a type for generic type checking support | ||
interface CustomModel { | ||
foo: string; | ||
bar: string; | ||
} | ||
amqpConnection.publish<CustomModel>('some-exchange', 'routing-key', {}); | ||
// this will now show an error that you are missing properties: foo, bar | ||
``` | ||
@@ -431,0 +437,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132610
1082
549