@ejfdelgado/ejflab-back 1.27.2 → 1.28.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.27.2",
3
+ "version": "1.28.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
@@ -85,7 +85,7 @@ export class PostgresSrv {
85
85
  }
86
86
 
87
87
  static async executeTextInTransaction(sql, model = {}) {
88
- const pool = PostgresSrv.getPool();
88
+ const pool = await PostgresSrv.getPool();
89
89
  const client = await pool.connect();
90
90
  await client.query("BEGIN");
91
91
  try {
@@ -106,7 +106,7 @@ export class PostgresSrv {
106
106
  console.log(sqlRendered);
107
107
  let localClient = false;
108
108
  if (!client) {
109
- const pool = PostgresSrv.getPool();
109
+ const pool = await PostgresSrv.getPool();
110
110
  localClient = true;
111
111
  client = await pool.connect();
112
112
  }
@@ -127,16 +127,26 @@ export class PostgresSrv {
127
127
  return await PostgresSrv.executeTextInTransaction(sql, model);
128
128
  }
129
129
 
130
- static getPool() {
130
+ static createPool() {
131
+ const params = PostgresSrv.getConnectionParams();
132
+ PostgresSrv.pool = new Pool({
133
+ user: params.user,
134
+ password: params.password,
135
+ host: params.host,
136
+ port: params.port,
137
+ database: params.database,
138
+ });
139
+ }
140
+
141
+ static async getPool() {
131
142
  if (PostgresSrv.pool == null) {
132
- const params = PostgresSrv.getConnectionParams();
133
- PostgresSrv.pool = new Pool({
134
- user: params.user,
135
- password: params.password,
136
- host: params.host,
137
- port: params.port,
138
- database: params.database,
139
- });
143
+ PostgresSrv.createPool();
144
+ }
145
+ try {
146
+ await PostgresSrv.pool.query('SELECT 1;');
147
+ } catch (err) {
148
+ console.log(err);
149
+ PostgresSrv.createPool();
140
150
  }
141
151
  return PostgresSrv.pool;
142
152
  }
@@ -427,6 +427,9 @@ export class SocketIOCall {
427
427
  const processor = parts[1];
428
428
  const instance = parts[2];
429
429
  decoded['method'] = parts[3];
430
+ decoded['pig'] = {
431
+ now: new Date().getTime(),
432
+ };
430
433
 
431
434
  // Get socket destiny if channel is websocket
432
435
  let socketId = null;