@lad-tech/nsc-toolkit 2.0.5 → 2.1.0

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.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,6 @@
1
- ## [2.0.5](https://github.com/lad-tech/nsc-toolkit/compare/v2.0.4...v2.0.5) (2026-02-12)
1
+ # [2.1.0](https://github.com/lad-tech/nsc-toolkit/compare/v2.0.5...v2.1.0) (2026-02-13)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * ci/cd ([#163](https://github.com/lad-tech/nsc-toolkit/issues/163)) ([783b7eb](https://github.com/lad-tech/nsc-toolkit/commit/783b7ebe649962d7ffed08f20150d922258257d5))
7
- * fix ci/cd ([#165](https://github.com/lad-tech/nsc-toolkit/issues/165)) ([c899213](https://github.com/lad-tech/nsc-toolkit/commit/c899213f1c429e9689218230b83a1da580e4e57e))
8
- * Logic create singleton object ([#159](https://github.com/lad-tech/nsc-toolkit/issues/159)) ([eaadf01](https://github.com/lad-tech/nsc-toolkit/commit/eaadf015f9f6b733c0b4d891e8b385ca22a14106))
9
- * publish ci/cd ([#161](https://github.com/lad-tech/nsc-toolkit/issues/161)) ([0138bfc](https://github.com/lad-tech/nsc-toolkit/commit/0138bfcd35c406637d64369f75c5d3f3e383158b))
10
- * return npm token ([#169](https://github.com/lad-tech/nsc-toolkit/issues/169)) ([3d6a40f](https://github.com/lad-tech/nsc-toolkit/commit/3d6a40f271e775861ef8c7002c9abf7b98ff5943))
11
- * up semantic release version ([#167](https://github.com/lad-tech/nsc-toolkit/issues/167)) ([d1d6d99](https://github.com/lad-tech/nsc-toolkit/commit/d1d6d99bf124ff6d4fc2094d1107b1155fca9d76))
6
+ * new race flar in method ([#171](https://github.com/lad-tech/nsc-toolkit/issues/171)) ([61885f5](https://github.com/lad-tech/nsc-toolkit/commit/61885f55829152f685b48c1158df46780196d594))
package/dist/Service.js CHANGED
@@ -460,13 +460,17 @@ class Service extends Root_1.Root {
460
460
  const { methods } = this.options;
461
461
  try {
462
462
  methods.forEach(async (Method) => {
463
- var _a;
463
+ var _a, _b, _c, _d, _e, _f;
464
464
  if ((_a = Method.settings.options) === null || _a === void 0 ? void 0 : _a.useStream) {
465
465
  this.httpMethods.set(Method.settings.action, Method);
466
466
  return;
467
467
  }
468
468
  const subject = `${this.serviceName}.${Method.settings.action}`;
469
- const subscription = this.broker.subscribe(subject, { queue: this.serviceName });
469
+ const isRace = (_b = Method.settings.options) === null || _b === void 0 ? void 0 : _b.race;
470
+ const isNotWebStreamRequest = !((_d = (_c = Method.settings.options) === null || _c === void 0 ? void 0 : _c.useStream) === null || _d === void 0 ? void 0 : _d.request);
471
+ const isNotWebStreamResponse = !((_f = (_e = Method.settings.options) === null || _e === void 0 ? void 0 : _e.useStream) === null || _f === void 0 ? void 0 : _f.response);
472
+ const queue = isRace && isNotWebStreamRequest && isNotWebStreamResponse ? {} : { queue: this.serviceName };
473
+ const subscription = this.broker.subscribe(subject, queue);
470
474
  this.subscriptions.push(subscription);
471
475
  for await (const message of subscription) {
472
476
  const { payload, baggage } = (0, nats_1.JSONCodec)().decode(message.data);
@@ -12,6 +12,7 @@ export interface MethodOptions {
12
12
  request?: boolean;
13
13
  response?: boolean;
14
14
  };
15
+ race?: boolean;
15
16
  }
16
17
  export interface MethodSettings {
17
18
  action: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",