Skip to content

Commit 21912e4

Browse files
authored
Update puppeteer.ts
1 parent 95abd16 commit 21912e4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

api/_lib/puppeteer.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import chrome from "chrome-aws-lambda";
33
let _page: Page | null;
44

55
async function getPage() {
6-
if (_page) return _page;
7-
const options = {
8-
args: chrome.args,
9-
executablePath: await chrome.executablePath,
10-
headless: chrome.headless
11-
};
12-
const browser = await launch(options);
13-
_page = await browser.newPage();
14-
return _page;
6+
if (_page) return _page;
7+
const options = {
8+
args: chrome.args,
9+
executablePath: await chrome.executablePath,
10+
headless: chrome.headless,
11+
};
12+
const browser = await launch(options);
13+
_page = await browser.newPage();
14+
return _page;
1515
}
1616

1717
export async function getScreenshot(url, width, height) {
18-
const page = await getPage();
19-
await page.goto(url);
20-
await page.setViewport({ width: Number(width) || 1280, height: Number(height) || 720, deviceScaleFactor: 2 });
21-
const file = await page.screenshot();
22-
return file;
18+
const page = await getPage();
19+
await page.goto(url);
20+
await page.setViewport({ width: Number(width) || 1280, height: Number(height) || 720, deviceScaleFactor: 2 });
21+
const file = await page.screenshot();
22+
return file;
2323
}

0 commit comments

Comments
 (0)