Skip to content

Commit

Permalink
Merge pull request #22 from Gavant/change-chromium
Browse files Browse the repository at this point in the history
Update chromium and node
  • Loading branch information
bakerac4 authored May 6, 2024
2 parents 15b0550 + 9ff4314 commit bd6c2e3
Show file tree
Hide file tree
Showing 7 changed files with 8,125 additions and 6,029 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- uses: actions/checkout@v3
- uses: volta-cli/action@v1
with:
node-version: 14.x
node-version: 18.x
yarn-version: 1.x
- name: Install Dependencies
run: yarn install --frozen-lockfile
run: yarn install
- name: Lint
run: yarn lint
- name: Run Tests
Expand Down
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
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"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",
"yarn": "3.6.4"
}
}
20 changes: 11 additions & 9 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 @@ -29,7 +30,7 @@ export default class PdfGenerationService {
});
console.log(`Puppeteer visited page located at ${pdfGenerationRequest.url}`);
const options = { ...htmlToPdfPrintOptions, ...pdfGenerationRequest.pdfOptions };
await report.pdfPage(page, {
await report.pdfPage(page as any, {

Check warning on line 33 in src/services/pdf-generation.ts

View workflow job for this annotation

GitHub Actions / Tests

Unexpected any. Specify a different type
path: pdfGenerationRequest.localFilePath,
...options
});
Expand All @@ -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 bd6c2e3

Please sign in to comment.