@ejfdelgado/ejflab-back 1.27.1 → 1.27.3

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.1",
3
+ "version": "1.27.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
@@ -106,7 +106,9 @@ export class MainHandler {
106
106
  if (rootFolder) {
107
107
  options.push(path.join(rootFolder, filename));
108
108
  }
109
- options.push(path.join(MainHandler.LOCAL_FOLDER1, filename));
109
+ if (process.env.ENV != "pro") {
110
+ options.push(path.join(MainHandler.LOCAL_FOLDER1, filename));
111
+ }
110
112
  options.push(path.join(MainHandler.LOCAL_FOLDER, filename));
111
113
 
112
114
  // Check which exists first, if not resolve null with log
@@ -122,6 +124,7 @@ export class MainHandler {
122
124
  if (!selected) {
123
125
  console.log(`Files not found ${options}`);
124
126
  resolve(null);
127
+ return;
125
128
  }
126
129
 
127
130
  const somePath = selected;
@@ -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
  }