-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
43 lines (39 loc) · 918 Bytes
/
handler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');
const { invoke } = require('./src/test-script');
module.exports.exec = async () => {
let response;
try {
const chromiumOptions = {
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: chromium.headless,
args: [
...chromium.args,
'--no-sandbox',
],
};
const browser = await puppeteer.launch(chromiumOptions);
const start = Date.now();
await invoke(browser);
const duration = Date.now() - start;
browser.close();
response = {
statusCode: 200,
body: {
duration: duration,
},
};
} catch(e) {
console.log('ERROR', e);
response = {
statusCode: 200,
body: {
error: e,
},
};
} finally {
return response;
}
};