@saihu/common 1.1.73 → 1.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export * from './bootstrap';
2
2
  export * from './topology';
3
+ export * from './saihu-rabbit.module';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./bootstrap"), exports);
18
18
  __exportStar(require("./topology"), exports);
19
+ __exportStar(require("./saihu-rabbit.module"), exports);
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export declare class SaihuRabbitModule {
3
+ static register(): DynamicModule;
4
+ }
5
+ //# sourceMappingURL=saihu-rabbit.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saihu-rabbit.module.d.ts","sourceRoot":"","sources":["../../src/messaging/saihu-rabbit.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAMvD,qBACa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,IAAI,aAAa;CA8CjC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var SaihuRabbitModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SaihuRabbitModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const config_1 = require("@nestjs/config");
13
+ const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
14
+ const bootstrap_1 = require("./bootstrap"); // your existing helper
15
+ const topology_1 = require("../messaging/topology");
16
+ let SaihuRabbitModule = SaihuRabbitModule_1 = class SaihuRabbitModule {
17
+ static register() {
18
+ return {
19
+ module: SaihuRabbitModule_1,
20
+ imports: [
21
+ config_1.ConfigModule,
22
+ nestjs_rabbitmq_1.RabbitMQModule.forRootAsync({
23
+ inject: [config_1.ConfigService],
24
+ useFactory: (config) => (0, bootstrap_1.createRabbitMQConfig)({
25
+ uri: config.get('RABBIT_URI'),
26
+ }),
27
+ }),
28
+ ],
29
+ providers: [
30
+ {
31
+ provide: 'SAIHU_RABBIT_TOPOLOGY',
32
+ inject: [nestjs_rabbitmq_1.AmqpConnection],
33
+ useFactory: async (amqp) => {
34
+ await amqp.managedChannel.addSetup(async (channel) => {
35
+ // 1️⃣ Assert all DLX exchanges
36
+ for (const ex of Object.values(topology_1.Exchanges)) {
37
+ if (ex.endsWith('.dlx')) {
38
+ await channel.assertExchange(ex, 'topic', { durable: true });
39
+ }
40
+ }
41
+ // 2️⃣ Assert shared DLQ queues (one per DLX routing key)
42
+ for (const [ex, keys] of Object.entries(topology_1.RoutingKeys)) {
43
+ if (!ex.endsWith('.dlx'))
44
+ continue;
45
+ for (const rk of Object.values(keys)) {
46
+ const dlqQueue = `q.${rk}`; // ✅ shared name
47
+ await channel.assertQueue(dlqQueue, { durable: true });
48
+ await channel.bindQueue(dlqQueue, ex, rk);
49
+ }
50
+ }
51
+ });
52
+ return true;
53
+ },
54
+ },
55
+ ],
56
+ exports: [nestjs_rabbitmq_1.RabbitMQModule],
57
+ };
58
+ }
59
+ };
60
+ exports.SaihuRabbitModule = SaihuRabbitModule;
61
+ exports.SaihuRabbitModule = SaihuRabbitModule = SaihuRabbitModule_1 = __decorate([
62
+ (0, common_1.Module)({})
63
+ ], SaihuRabbitModule);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saihu/common",
3
- "version": "1.1.73",
3
+ "version": "1.1.75",
4
4
  "description": "Common utilities for NestJS applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",