@websy/websy-designs 1.11.4 → 1.11.5
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.
|
@@ -16,12 +16,13 @@ class MySqlHelper {
|
|
|
16
16
|
this.onReadyAuthCallbackFn = null
|
|
17
17
|
this.onReadyShopCallbackFn = null
|
|
18
18
|
}
|
|
19
|
-
init () {
|
|
19
|
+
init (onError) {
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
const ConnectionConfig = require('mysql/lib/ConnectionConfig')
|
|
22
22
|
const config = new ConnectionConfig(process.env.DATABASE_URL)
|
|
23
23
|
config.connectionLimit = process.env.DB_CONNECTION_LIMIT || 5
|
|
24
|
-
this.pool = mysql.createPool(config)
|
|
24
|
+
this.pool = mysql.createPool(config)
|
|
25
|
+
this.onError = onError
|
|
25
26
|
// this.pool.getConnection((err, connection) => {
|
|
26
27
|
// if (err) {
|
|
27
28
|
// reject(err)
|
|
@@ -38,7 +39,7 @@ class MySqlHelper {
|
|
|
38
39
|
// resolve()
|
|
39
40
|
// }
|
|
40
41
|
// })
|
|
41
|
-
// this.pool.on('connection', function (connection) {
|
|
42
|
+
// this.pool.on('connection', function (connection) {
|
|
42
43
|
this.pool.on('acquire', function (connection) {
|
|
43
44
|
// console.log('Connection %d acquired', connection.threadId)
|
|
44
45
|
})
|
|
@@ -149,7 +150,10 @@ class MySqlHelper {
|
|
|
149
150
|
// else {
|
|
150
151
|
this.pool.query(query, (error, results, fields) => {
|
|
151
152
|
if (error) {
|
|
152
|
-
// return this.client.rollback(() => {
|
|
153
|
+
// return this.client.rollback(() => {
|
|
154
|
+
if (this.onError && typeof this.onError === 'function') {
|
|
155
|
+
this.onError(error)
|
|
156
|
+
}
|
|
153
157
|
reject(error)
|
|
154
158
|
// })
|
|
155
159
|
}
|
|
@@ -201,8 +201,7 @@ ${
|
|
|
201
201
|
`
|
|
202
202
|
lastHTML = html
|
|
203
203
|
convertHTMLToPDF(html, data.name || utils.createIdentity(), (err, pdf) => {
|
|
204
|
-
console.log('info', `HTML converted to PDF`)
|
|
205
|
-
console.log(html.split(0, 5000))
|
|
204
|
+
console.log('info', `HTML converted to PDF`)
|
|
206
205
|
// setTimeout(() => {
|
|
207
206
|
// try {
|
|
208
207
|
// // fs.unlinkSync(`${process.env.APP_ROOT}/pdf/${pdfId}.pdf`)
|
|
@@ -67,7 +67,7 @@ module.exports = function (options) {
|
|
|
67
67
|
app.use('/pdf', require(`./routes/${version}/pdf`))
|
|
68
68
|
if (options.useDB === true) {
|
|
69
69
|
const dbHelper = require(`./helpers/${version}/${options.dbEngine}Helper`)
|
|
70
|
-
dbHelper.init(options.
|
|
70
|
+
dbHelper.init(options.dbOnError || {}).then(() => {
|
|
71
71
|
app.set('trust proxy', 1)
|
|
72
72
|
app.use(cookieParser(process.env.SESSION_SECRET))
|
|
73
73
|
let cookieConfig = {
|