@lad-tech/nsc-toolkit 1.15.0 → 1.15.1

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,6 +1,6 @@
1
- # [1.15.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.14.0...v1.15.0) (2023-08-16)
1
+ ## [1.15.1](https://github.com/lad-tech/nsc-toolkit/compare/v1.15.0...v1.15.1) (2023-08-16)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * symbol().to syntax ([#72](https://github.com/lad-tech/nsc-toolkit/issues/72)) ([90e361e](https://github.com/lad-tech/nsc-toolkit/commit/90e361e001ad0b0686ed066e15102fb90209ead9))
6
+ * singlton inject ([9627f1c](https://github.com/lad-tech/nsc-toolkit/commit/9627f1c6c5b82e73b910a8480697dcafa1abd14f))
package/dist/Container.js CHANGED
@@ -107,13 +107,14 @@ class Container {
107
107
  throw new Error(`Unknown dependency type for key ${key.toString()}`);
108
108
  }
109
109
  async initDependencies() {
110
- var _a;
110
+ var _a, _b;
111
111
  const initialized = [];
112
112
  for await (const [key, dependency] of this.container) {
113
113
  if (this.isAdapterDependency(dependency) && ((_a = dependency.options) === null || _a === void 0 ? void 0 : _a.init) && !this.singltons.has(key)) {
114
114
  const instance = this.getInstance(key);
115
115
  await (instance === null || instance === void 0 ? void 0 : instance.init());
116
116
  initialized.push(instance);
117
+ this.singltons.set(key, { value: instance, init: (_b = dependency.options) === null || _b === void 0 ? void 0 : _b.init });
117
118
  }
118
119
  }
119
120
  return initialized;
@@ -29,7 +29,7 @@ declare class Container {
29
29
  bind<R extends Record<string, any>>(key: symbol, type: typeof DependencyType.CONSTANT, value: R): void;
30
30
  symbol(key: symbol): {
31
31
  to: {
32
- Adapter: <R extends Record<string, any>>(value: Adapter<R & import("./interfaces").GracefulShutdownAdditionalService & {
32
+ Adapter: <R extends Record<string, any>>(value: Adapter<R> | Adapter<R & import("./interfaces").GracefulShutdownAdditionalService & {
33
33
  init: () => Promise<any>;
34
34
  }>, options?: AdapterOptions) => void;
35
35
  Singlton: <R_1 extends Record<string, any>>(value: Adapter<R_1>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",