Skip to content

Commit

Permalink
Update chromium and node
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerac4 committed May 6, 2024
1 parent 15b0550 commit 8511d7b
Show file tree
Hide file tree
Showing 6 changed files with 8,121 additions and 6,026 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
.idea/*

.DS_Store
.yarn
coverage
*.log
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
coverage
*.log
.gitlab-ci.yml
.yarn

yarn.lock
/*.tgz
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.56.0",
"@aws-sdk/s3-request-presigner": "^3.120.0",
"chrome-aws-lambda": "^10.1.0",
"@sparticuz/chromium": "122",
"puppeteer-core": "^13.5.1",
"puppeteer-report": "^3.0.2"
},
"publishConfig": {
"access": "public"
},
"volta": {
"node": "14.19.1"
"node": "18.16.0"
}
}
18 changes: 10 additions & 8 deletions src/services/pdf-generation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import chromium from 'chrome-aws-lambda';
import { PDFOptions } from 'puppeteer-core';
import puppeteer, { PDFOptions } from 'puppeteer-core';
import report from 'puppeteer-report';

import chromium from '@sparticuz/chromium';

import PdfGenerationRequest from '../requests/request';

const DEFAULT_PRINT_OPTIONS: PDFOptions = {
Expand Down Expand Up @@ -40,13 +41,14 @@ export default class PdfGenerationService {
}

async launchBrowser(pdfGenerationRequest: PdfGenerationRequest) {
return await chromium.puppeteer.launch({
const chromiumPath = await chromium.executablePath();
const options = {
args: chromium.args,
defaultViewport: null,
executablePath: await chromium.executablePath,
headless: chromium.headless,
ignoreHTTPSErrors: true,
executablePath: chromiumPath,
headless: !!process?.env?.BROWSER_HEADLESS === false ? false : true,
...pdfGenerationRequest.browserOptions
});
};

return await puppeteer.launch(options);
}
}
Loading

0 comments on commit 8511d7b

Please sign in to comment.