fix(core): Fix candidate handling in PDF generation
This commit is contained in:
parent
12a581ced9
commit
3d7bb37849
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-11-30 - 3.1.8 - fix(core)
|
||||||
|
Fix candidate handling in PDF generation
|
||||||
|
|
||||||
|
- Added error handling for missing PDF candidates in server requests.
|
||||||
|
- Updated devDependencies and dependencies to latest versions for better stability and new features.
|
||||||
|
- Patched header retrieval logic during PDF generation for security check.
|
||||||
|
|
||||||
## 2024-09-27 - 3.1.7 - fix(dependencies)
|
## 2024-09-27 - 3.1.7 - fix(dependencies)
|
||||||
Update dependencies to latest versions
|
Update dependencies to latest versions
|
||||||
|
|
||||||
|
16
package.json
16
package.json
@ -14,12 +14,12 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.84",
|
"@git.zone/tsbuild": "^2.2.0",
|
||||||
"@git.zone/tsdoc": "^1.3.12",
|
"@git.zone/tsdoc": "^1.4.2",
|
||||||
"@git.zone/tsrun": "^1.2.49",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@git.zone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@push.rocks/tapbundle": "^5.3.0",
|
"@push.rocks/tapbundle": "^5.5.3",
|
||||||
"@types/node": "^22.7.4"
|
"@types/node": "^22.10.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartbuffer": "^3.0.4",
|
"@push.rocks/smartbuffer": "^3.0.4",
|
||||||
@ -31,10 +31,10 @@
|
|||||||
"@push.rocks/smartpuppeteer": "^2.0.2",
|
"@push.rocks/smartpuppeteer": "^2.0.2",
|
||||||
"@push.rocks/smartunique": "^3.0.9",
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
"@tsclass/tsclass": "^4.1.2",
|
"@tsclass/tsclass": "^4.1.2",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^5.0.0",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.1",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"pdf2json": "3.0.5",
|
"pdf2json": "3.1.4",
|
||||||
"pdf2pic": "^3.1.3"
|
"pdf2pic": "^3.1.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
4126
pnpm-lock.yaml
generated
4126
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartpdf',
|
name: '@push.rocks/smartpdf',
|
||||||
version: '3.1.7',
|
version: '3.1.8',
|
||||||
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,13 @@ export class SmartPdf {
|
|||||||
// setup server
|
// setup server
|
||||||
const app = plugins.express();
|
const app = plugins.express();
|
||||||
app.get('/:pdfId', (req, res) => {
|
app.get('/:pdfId', (req, res) => {
|
||||||
res.setHeader('PDF-ID', this._candidates[req.params.pdfId].pdfId);
|
const wantedCandidate = this._candidates[req.params.pdfId];
|
||||||
res.send(this._candidates[req.params.pdfId].htmlString);
|
if (!wantedCandidate) {
|
||||||
|
console.log(`${req.url} not attached to a candidate`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.setHeader('pdf-id', wantedCandidate.pdfId);
|
||||||
|
res.send(wantedCandidate.htmlString);
|
||||||
});
|
});
|
||||||
this.htmlServerInstance = plugins.http.createServer(app);
|
this.htmlServerInstance = plugins.http.createServer(app);
|
||||||
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
|
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
|
||||||
@ -84,7 +89,6 @@ export class SmartPdf {
|
|||||||
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
|
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
|
||||||
waitUntil: 'networkidle2',
|
waitUntil: 'networkidle2',
|
||||||
});
|
});
|
||||||
// await plugins.smartdelay.delayFor(1000);
|
|
||||||
const headers = response.headers();
|
const headers = response.headers();
|
||||||
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
|
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
|
||||||
console.log('Error! Headers do not match. For security reasons no pdf is being emitted!');
|
console.log('Error! Headers do not match. For security reasons no pdf is being emitted!');
|
||||||
|
Loading…
Reference in New Issue
Block a user