dt-common-device 13.8.8 → 13.9.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.
@@ -1,8 +1,8 @@
1
1
  import { IInternalEvent } from "../events/interfaces/IInternalEvent";
2
2
  export interface ILogger {
3
- info(message: string, ...args: any[]): void;
4
- warn(message: string, ...args: any[]): void;
5
- error(message: string, ...args: any[]): void;
3
+ info(...args: any[]): void;
4
+ warn(...args: any[]): void;
5
+ error(...args: any[]): void;
6
6
  }
7
7
  type AllowedSource = "ACCESS_SERVICE" | "ADMIN_SERVICE" | "ENERGY_SERVICE" | "REMOTE_SERVICE" | "SCHEDULE_SERVICE" | "MIGRATION" | "OPERATION_NODE_SERVICE" | "NOTIFICATION_SERVICE";
8
8
  export type IConfig = {
package/dist/db/db.js CHANGED
@@ -11,45 +11,49 @@ exports.getWebhookPostgresClient = getWebhookPostgresClient;
11
11
  const pg_1 = require("pg");
12
12
  const config_1 = require("../config/config");
13
13
  const mongoose_1 = __importDefault(require("mongoose"));
14
+ let adminPool = null;
15
+ let accessPool = null;
16
+ let pmsPool = null;
17
+ let webhookPool = null;
14
18
  function getPostgresClient() {
15
19
  const URI = (0, config_1.getAdminPostgresDbUri)();
16
- let pool = null;
17
- if (!pool) {
18
- pool = new pg_1.Pool({
19
- connectionString: URI,
20
- });
21
- }
22
- return pool;
20
+ adminPool ?? (adminPool = new pg_1.Pool({
21
+ connectionString: URI,
22
+ connectionTimeoutMillis: 5000,
23
+ idleTimeoutMillis: 30000,
24
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Admin Pool connection error`)));
25
+ (0, config_1.getLogger)().info(`[Postgres] Admin Pool initialized`);
26
+ return adminPool;
23
27
  }
24
28
  function getAccessPostgresClient() {
25
29
  const URI = (0, config_1.getAccessPostgresDbUri)();
26
- let pool = null;
27
- if (!pool) {
28
- pool = new pg_1.Pool({
29
- connectionString: URI,
30
- });
31
- }
32
- return pool;
30
+ accessPool ?? (accessPool = new pg_1.Pool({
31
+ connectionString: URI,
32
+ connectionTimeoutMillis: 5000,
33
+ idleTimeoutMillis: 30000,
34
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Access Pool connection error`)));
35
+ (0, config_1.getLogger)().info(`[Postgres] Access Pool initialized`);
36
+ return accessPool;
33
37
  }
34
38
  function getPmsPostgresClient() {
35
39
  const URI = (0, config_1.getPmsPostgresDbUri)();
36
- let pool = null;
37
- if (!pool) {
38
- pool = new pg_1.Pool({
39
- connectionString: URI,
40
- });
41
- }
42
- return pool;
40
+ pmsPool ?? (pmsPool = new pg_1.Pool({
41
+ connectionString: URI,
42
+ connectionTimeoutMillis: 5000,
43
+ idleTimeoutMillis: 30000,
44
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] PMS Pool connection error`)));
45
+ (0, config_1.getLogger)().info(`[Postgres] PMS Pool initialized`);
46
+ return pmsPool;
43
47
  }
44
48
  function getWebhookPostgresClient() {
45
49
  const URI = (0, config_1.getWebhookPostgresDbUri)();
46
- let pool = null;
47
- if (!pool) {
48
- pool = new pg_1.Pool({
49
- connectionString: URI,
50
- });
51
- }
52
- return pool;
50
+ webhookPool ?? (webhookPool = new pg_1.Pool({
51
+ connectionString: URI,
52
+ connectionTimeoutMillis: 5000,
53
+ idleTimeoutMillis: 30000,
54
+ }).on("error", (err) => (0, config_1.getLogger)().error(err, `[Postgres] Webhook Pool connection error`)));
55
+ (0, config_1.getLogger)().info(`[Postgres] Webhook Pool initialized`);
56
+ return webhookPool;
53
57
  }
54
58
  const connectDatabase = async () => {
55
59
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.8.8",
3
+ "version": "13.9.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [