@websy/websy-designs 1.12.15-alpha.0 → 1.12.15-alpha.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.
|
@@ -4,49 +4,6 @@ const report = require('./puppeteer-report/index')
|
|
|
4
4
|
const fs = require('fs')
|
|
5
5
|
const utils = require('../../utils')
|
|
6
6
|
const http = require('http')
|
|
7
|
-
let lastHTML = ''
|
|
8
|
-
let testHTML = `
|
|
9
|
-
<!DOCTYPE html>
|
|
10
|
-
<html lang="en">
|
|
11
|
-
<head>
|
|
12
|
-
<meta charset="UTF-8">
|
|
13
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
14
|
-
<link rel="stylesheet" href="/external/@websy/websy-designs/dist/websy-designs.min.css">
|
|
15
|
-
<link rel="stylesheet" href="/styles/pdf.min.css">
|
|
16
|
-
<style>
|
|
17
|
-
html {
|
|
18
|
-
-webkit-print-color-adjust: exact;
|
|
19
|
-
width: unset;
|
|
20
|
-
background-color: white;
|
|
21
|
-
}
|
|
22
|
-
body {
|
|
23
|
-
width: unset;
|
|
24
|
-
background-color: white;
|
|
25
|
-
}
|
|
26
|
-
#header {
|
|
27
|
-
margin: 0 15px;
|
|
28
|
-
max-height: unset;
|
|
29
|
-
}
|
|
30
|
-
#footer {
|
|
31
|
-
margin: 0 15px;
|
|
32
|
-
}
|
|
33
|
-
</style>
|
|
34
|
-
</head>
|
|
35
|
-
|
|
36
|
-
<body>
|
|
37
|
-
<div id="app">
|
|
38
|
-
<div id="header">
|
|
39
|
-
Header
|
|
40
|
-
</div>
|
|
41
|
-
${(new Array(300).fill({}).map((d, i) => '<p>val ' + i + '</p>')).join('')}
|
|
42
|
-
<div id="footer">
|
|
43
|
-
Footer
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</body>
|
|
47
|
-
|
|
48
|
-
</html>
|
|
49
|
-
`
|
|
50
7
|
|
|
51
8
|
let convertHTMLToPDF = (html, name, callback, options_in = null, displayHeaderFooter) => {
|
|
52
9
|
const pOptions = {
|
|
@@ -198,22 +155,10 @@ ${
|
|
|
198
155
|
</div>
|
|
199
156
|
</body>
|
|
200
157
|
</html>
|
|
201
|
-
`
|
|
202
|
-
lastHTML = html
|
|
158
|
+
`
|
|
203
159
|
convertHTMLToPDF(html, data.name || utils.createIdentity(), (err, pdf) => {
|
|
204
160
|
console.log('info', `HTML converted to PDF`)
|
|
205
|
-
// setTimeout(() => {
|
|
206
|
-
// try {
|
|
207
|
-
// // fs.unlinkSync(`${process.env.APP_ROOT}/pdf/${pdfId}.pdf`)
|
|
208
|
-
// }
|
|
209
|
-
// catch (error) {
|
|
210
|
-
// console.log('Could not remove temp PDF')
|
|
211
|
-
// }
|
|
212
|
-
// }, 120000)
|
|
213
161
|
callbackFn(err, pdf)
|
|
214
162
|
}, data.options, (header !== '' || footer !== ''))
|
|
215
|
-
}
|
|
216
|
-
getLastHTML: () => {
|
|
217
|
-
return lastHTML
|
|
218
|
-
}
|
|
163
|
+
}
|
|
219
164
|
}
|
|
@@ -67,9 +67,7 @@ function APIRoutes (dbHelper, authHelper) {
|
|
|
67
67
|
user = req.session.user
|
|
68
68
|
}
|
|
69
69
|
if (req.body && req.body.data) {
|
|
70
|
-
const queries = dbHelper.buildUpsert(req.params.entity, req.body.data, user)
|
|
71
|
-
console.log(queries)
|
|
72
|
-
|
|
70
|
+
const queries = dbHelper.buildUpsert(req.params.entity, req.body.data, user)
|
|
73
71
|
dbHelper.executeUpsert(0, queries, (err) => {
|
|
74
72
|
if (err) {
|
|
75
73
|
res.json(err)
|
|
@@ -7,13 +7,11 @@ router.get('/', (req, res) => {
|
|
|
7
7
|
// res.setHeader('Content-Disposition', 'attachment')
|
|
8
8
|
// res.setHeader('filename', `${req.params.name || utils.createIdentity()}.pdf`)
|
|
9
9
|
res.setHeader('Content-Disposition', `attachment;filename=${utils.createIdentity()}.pdf`)
|
|
10
|
-
res.contentType('application/pdf')
|
|
11
|
-
console.log(req.session.pdf)
|
|
10
|
+
res.contentType('application/pdf')
|
|
12
11
|
res.send(req.session.pdf)
|
|
13
12
|
})
|
|
14
13
|
|
|
15
|
-
router.post('/', (req, res) => {
|
|
16
|
-
console.log('creating pdf in wd')
|
|
14
|
+
router.post('/', (req, res) => {
|
|
17
15
|
pdfHelper.createPDF(req.body, (err, pdf) => {
|
|
18
16
|
if (err) {
|
|
19
17
|
res.status(400)
|
|
@@ -21,6 +21,7 @@ module.exports = function (options) {
|
|
|
21
21
|
}
|
|
22
22
|
const app = express()
|
|
23
23
|
app.set('trust proxy', 1)
|
|
24
|
+
app.set('case sensitive routing', true)
|
|
24
25
|
process.env.wdRoot = __dirname
|
|
25
26
|
let version = options.version || 'v1'
|
|
26
27
|
process.env.WD_VERSION = version
|
|
@@ -53,9 +54,6 @@ module.exports = function (options) {
|
|
|
53
54
|
next()
|
|
54
55
|
}
|
|
55
56
|
app.use(allowCrossDomain)
|
|
56
|
-
app.get('/health', (req, res) => {
|
|
57
|
-
res.json('OK')
|
|
58
|
-
})
|
|
59
57
|
if (options.useRecaptcha === true && process.env.RECAPTCHA_SECRET) {
|
|
60
58
|
app.use('/google', require(`./routes/${version}/recaptcha`))
|
|
61
59
|
}
|