geniebox-shared-lib 1.0.0 → 1.0.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.
@@ -8,10 +8,6 @@ export interface SharedModuleOptions {
8
8
  protoPath: string;
9
9
  url: string;
10
10
  };
11
- account?: {
12
- protoPath: string;
13
- url: string;
14
- };
15
11
  }
16
12
  export declare class SharedModule {
17
13
  static forRoot(options?: SharedModuleOptions): DynamicModule;
@@ -16,6 +16,7 @@ const auth_client_1 = require("./auth/auth.client");
16
16
  let SharedModule = SharedModule_1 = class SharedModule {
17
17
  static forRoot(options = {}) {
18
18
  const clients = [];
19
+ const providers = [];
19
20
  if (options.user) {
20
21
  clients.push({
21
22
  name: "USER_PACKAGE",
@@ -26,6 +27,17 @@ let SharedModule = SharedModule_1 = class SharedModule {
26
27
  url: options.user.url,
27
28
  },
28
29
  });
30
+ providers.push({
31
+ provide: user_client_1.UsersClient,
32
+ useFactory: (client) => new user_client_1.UsersClient(client),
33
+ inject: ["USER_PACKAGE"],
34
+ });
35
+ }
36
+ else {
37
+ providers.push({
38
+ provide: user_client_1.UsersClient,
39
+ useValue: null,
40
+ });
29
41
  }
30
42
  if (options.auth) {
31
43
  clients.push({
@@ -37,12 +49,23 @@ let SharedModule = SharedModule_1 = class SharedModule {
37
49
  url: options.auth.url,
38
50
  },
39
51
  });
52
+ providers.push({
53
+ provide: auth_client_1.AuthClient,
54
+ useFactory: (client) => new auth_client_1.AuthClient(client),
55
+ inject: ["AUTH_PACKAGE"],
56
+ });
57
+ }
58
+ else {
59
+ providers.push({
60
+ provide: auth_client_1.AuthClient,
61
+ useValue: null,
62
+ });
40
63
  }
41
64
  return {
42
65
  module: SharedModule_1,
43
66
  imports: clients.length ? [microservices_1.ClientsModule.register(clients)] : [],
44
- providers: [user_client_1.UsersClient, auth_client_1.AuthClient],
45
- exports: [user_client_1.UsersClient, auth_client_1.AuthClient],
67
+ providers,
68
+ exports: providers.map((p) => p.provide),
46
69
  };
47
70
  }
48
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geniebox-shared-lib",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared NestJS library with gRPC clients",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",