File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,21 @@ import chrome from "chrome-aws-lambda";
33let _page : Page | null ;
44
55async 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
1717export 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}
You can’t perform that action at this time.
0 commit comments