Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
47 lines (37 loc) · 1.34 KB

File metadata and controls

47 lines (37 loc) · 1.34 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
45
46
47
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const ylt = require('yellowlabtools');
// noinspection JSUnusedLocalSymbols
async function runner({id, url, options = {}, acl}, context) {
console.log(`Processing run #${id} on ${url}`);
// AWS S3 bucket and path
const bucket = process.env.RESULT_BUCKET_NAME;
const keyPrefix = `results/${id}`;
// Function that can save any file on S3 (JSON, screenshot,...)
const saveFile = async (path, content, contentType = undefined) => s3.putObject({Bucket: bucket, Key: `${keyPrefix}/${path}`, Body: content, ...(!!contentType ? {ContentType: contentType} : {}), ...(!!acl ? {ACL: acl} : {})})
.promise();
// Let's launch ylt
const result = await ylt(url, {...options, saveScreenshotFn: saveFile})
.then(async data => {
console.log(`Run succeeded`);
data.runId = id;
await saveFile('results.json', JSON.stringify(data), 'application/json');
return {
status: 'processed',
id,
bucket,
keyPrefix
};
})
.fail(error => {
console.log(`Run failed with error: ${error}`);
return {
status: 'failed',
id,
bucket,
errorMessage: error
};
});
return result;
}
module.exports = {runner};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.