@digitaldefiance/node-express-suite 2.1.62 → 2.1.63

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/README.md CHANGED
@@ -1111,6 +1111,10 @@ The following v1.x patterns still work in v2.0:
1111
1111
 
1112
1112
  ## ChangeLog
1113
1113
 
1114
+ ### Version 2.1.63
1115
+
1116
+ - Improve EmailRegistry
1117
+
1114
1118
  ### Version 2.1.62
1115
1119
 
1116
1120
  - Upates to test utils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/node-express-suite",
3
- "version": "2.1.62",
3
+ "version": "2.1.63",
4
4
  "description": "Generic express application and routing library with decorator support",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -3,6 +3,24 @@ declare class EmailServiceRegistry {
3
3
  private service?;
4
4
  setService(service: IEmailService): void;
5
5
  getService(): IEmailService;
6
+ /**
7
+ * Check if any email service is registered
8
+ */
9
+ hasService(): boolean;
10
+ /**
11
+ * Check if the registered service is an instance of a specific class
12
+ * @param serviceClass The class/constructor to check against
13
+ * @returns true if the registered service is an instance of the given class
14
+ * @example
15
+ * emailServiceRegistry.isServiceType(EmailService) // true if EmailService is registered
16
+ * emailServiceRegistry.isServiceType(DummyEmailService) // true if DummyEmailService is registered
17
+ */
18
+ isServiceType<T extends IEmailService>(serviceClass: new (...args: any[]) => T): boolean;
19
+ /**
20
+ * Get the constructor name of the registered service
21
+ * @returns The name of the service class, or undefined if no service is registered
22
+ */
23
+ getServiceTypeName(): string | undefined;
6
24
  }
7
25
  export declare const emailServiceRegistry: EmailServiceRegistry;
8
26
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"email-service-registry.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/registry/email-service-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,cAAM,oBAAoB;IACxB,OAAO,CAAC,OAAO,CAAC,CAAgB;IAEhC,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIxC,UAAU,IAAI,aAAa;CAQ5B;AAED,eAAO,MAAM,oBAAoB,sBAA6B,CAAC"}
1
+ {"version":3,"file":"email-service-registry.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/registry/email-service-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,cAAM,oBAAoB;IACxB,OAAO,CAAC,OAAO,CAAC,CAAgB;IAEhC,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIxC,UAAU,IAAI,aAAa;IAS3B;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;;;;OAOG;IACH,aAAa,CAAC,CAAC,SAAS,aAAa,EACnC,YAAY,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GACtC,OAAO;IAIV;;;OAGG;IACH,kBAAkB,IAAI,MAAM,GAAG,SAAS;CAGzC;AAED,eAAO,MAAM,oBAAoB,sBAA6B,CAAC"}
@@ -13,6 +13,30 @@ class EmailServiceRegistry {
13
13
  }
14
14
  return this.service;
15
15
  }
16
+ /**
17
+ * Check if any email service is registered
18
+ */
19
+ hasService() {
20
+ return this.service !== undefined;
21
+ }
22
+ /**
23
+ * Check if the registered service is an instance of a specific class
24
+ * @param serviceClass The class/constructor to check against
25
+ * @returns true if the registered service is an instance of the given class
26
+ * @example
27
+ * emailServiceRegistry.isServiceType(EmailService) // true if EmailService is registered
28
+ * emailServiceRegistry.isServiceType(DummyEmailService) // true if DummyEmailService is registered
29
+ */
30
+ isServiceType(serviceClass) {
31
+ return this.service !== undefined && this.service instanceof serviceClass;
32
+ }
33
+ /**
34
+ * Get the constructor name of the registered service
35
+ * @returns The name of the service class, or undefined if no service is registered
36
+ */
37
+ getServiceTypeName() {
38
+ return this.service?.constructor.name;
39
+ }
16
40
  }
17
41
  exports.emailServiceRegistry = new EmailServiceRegistry();
18
42
  //# sourceMappingURL=email-service-registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-service-registry.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/registry/email-service-registry.ts"],"names":[],"mappings":";;;AAAA,oEAGyC;AAGzC,MAAM,oBAAoB;IAChB,OAAO,CAAiB;IAEhC,UAAU,CAAC,OAAsB;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,uCAAsB,CAC9B,mCAAkB,CAAC,gCAAgC,CACpD,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAEY,QAAA,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"email-service-registry.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/registry/email-service-registry.ts"],"names":[],"mappings":";;;AAAA,oEAGyC;AAGzC,MAAM,oBAAoB;IAChB,OAAO,CAAiB;IAEhC,UAAU,CAAC,OAAsB;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,uCAAsB,CAC9B,mCAAkB,CAAC,gCAAgC,CACpD,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,aAAa,CACX,YAAuC;QAEvC,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,YAAY,YAAY,CAAC;IAC5E,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC;IACxC,CAAC;CACF;AAEY,QAAA,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}