@ejfdelgado/ejflab-back 1.31.0 → 1.31.2
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 +1 -1
- package/srv/MyPdf.mjs +9 -1
- package/srv/PostgresSrv.mjs +8 -7
package/package.json
CHANGED
package/srv/MyPdf.mjs
CHANGED
@@ -7,6 +7,14 @@ import { MyUtilities } from '@ejfdelgado/ejflab-common/src/MyUtilities.js';
|
|
7
7
|
import MyDatesBack from '@ejfdelgado/ejflab-common/src/MyDatesBack.mjs';
|
8
8
|
import { TranslateSrv } from "./TranslateSrv.mjs";
|
9
9
|
|
10
|
+
let executablePath = '/usr/bin/google-chrome';
|
11
|
+
if (process.platform === 'win32') {
|
12
|
+
executablePath = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
|
13
|
+
}
|
14
|
+
if (process.env.CHROME_PATH) {
|
15
|
+
executablePath = process.env.CHROME_PATH;
|
16
|
+
}
|
17
|
+
|
10
18
|
export class MyPdf {
|
11
19
|
static async localRender(template, model = {}, format = "pdf", extra = [], configuration, launch) {
|
12
20
|
const source = fs.readFileSync(`./src/assets/templates/pdf/${template}`, { encoding: "utf8" });
|
@@ -60,7 +68,7 @@ export class MyPdf {
|
|
60
68
|
if (!launch) {
|
61
69
|
launch = {
|
62
70
|
headless: 'new',
|
63
|
-
executablePath:
|
71
|
+
executablePath: executablePath,
|
64
72
|
args: [
|
65
73
|
"--no-sandbox",
|
66
74
|
"--disable-gpu",
|
package/srv/PostgresSrv.mjs
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import pg from "pg";
|
2
2
|
import fs from "fs";
|
3
3
|
import { MyTemplate } from "@ejfdelgado/ejflab-common/src/MyTemplate.js";
|
4
|
+
import { consoleSrv } from "./ConsoleSrv.mjs";
|
4
5
|
const { Pool } = pg;
|
5
6
|
|
6
7
|
export class PostgresSrv {
|
@@ -113,7 +114,7 @@ export class PostgresSrv {
|
|
113
114
|
|
114
115
|
static async executeText(sql, model = {}, client = null) {
|
115
116
|
const sqlRendered = PostgresSrv.renderer.render(sql, model);
|
116
|
-
|
117
|
+
consoleSrv.log(sqlRendered);
|
117
118
|
let localClient = false;
|
118
119
|
if (!client) {
|
119
120
|
const pool = await PostgresSrv.getPool();
|
@@ -149,10 +150,10 @@ export class PostgresSrv {
|
|
149
150
|
});
|
150
151
|
PostgresSrv.pool.on('error', (err) => {
|
151
152
|
// try reconnect given the tipe of error
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
consoleSrv.error("-------------------------------------");
|
154
|
+
consoleSrv.error("------------------ Handling error ---");
|
155
|
+
consoleSrv.error("-------------------------------------");
|
156
|
+
consoleSrv.error(JSON.stringify(err.message));
|
156
157
|
if (err.message == "read ETIMEDOUT") {
|
157
158
|
PostgresSrv.createPool();
|
158
159
|
}
|
@@ -217,9 +218,9 @@ export class PostgresSrv {
|
|
217
218
|
throw new Error(`Test ${i + 1} In: ${actual.in} Actual: ${returned} but expected ${actual.expected}`);
|
218
219
|
}
|
219
220
|
}
|
220
|
-
|
221
|
+
consoleSrv.log(`Test passed ${testsNumber.length}!`);
|
221
222
|
|
222
|
-
//
|
223
|
+
//consoleSrv.log(PostgresSrv.renderer.render('Hola ${name} with age ${age | sanitizeNumber : 0}', {name: "Edgar", age: undefined}));
|
223
224
|
}
|
224
225
|
}
|
225
226
|
|