How to use the chrome-aws-lambda.defaultViewport function in chrome-aws-lambda

To help you get started, we’ve selected a few chrome-aws-lambda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensult / cloud-reports / src / reporters / pdf / index.ts View on Github external
const getPuppeteer = async () => {
    try {
        const puppeteer = require('puppeteer');
        return await puppeteer.launch();
    } catch (error) {
        if (error.code === 'MODULE_NOT_FOUND') {
            console.log('Error(This package is used for local development) ', JSON.stringify(error, null, 2));
            try {
                const chromium = require('chrome-aws-lambda')
                return await chromium.puppeteer.launch({
                    args: chromium.args,
                    defaultViewport: chromium.defaultViewport,
                    executablePath: await chromium.executablePath,
                    headless: chromium.headless
                });
            } catch (_error) {
                throw error;
            }
        }
    }
}
github ireade / netlify-puppeteer-screenshot-demo / functions / take-screenshot / take-screenshot.js View on Github external
exports.handler = async (event, context) => {

    const pageToScreenshot = JSON.parse(event.body).pageToScreenshot;

    if (!pageToScreenshot) return {
        statusCode: 400,
        body: JSON.stringify({ message: 'Page URL not defined' })
    }

    const browser = await chromium.puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
    });
    
    const page = await browser.newPage();

    await page.goto(pageToScreenshot, { waitUntil: 'networkidle2' });

    const screenshot = await page.screenshot({ encoding: 'binary' });

    await browser.close();
  
    return {
        statusCode: 200,
        body: JSON.stringify({ 
            message: `Complete screenshot of ${pageToScreenshot}`,
github faastjs / examples / aws-puppeteer-ts / functions.ts View on Github external
export async function runPuppeteer(url: string) {
    const browser = await puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless
    });
    try {
        let page = await browser.newPage();
        await page.goto(url);
        const title = await page.title();
        const screenshot = await page.screenshot({ encoding: "binary" });
        return { title, screenshot };
    } finally {
        if (browser !== null) {
            await browser.close();
        }
    }
}
github tophat / sanity-runner / service / src / jestSetup / puppeteer / setup.js View on Github external
module.exports = async () => {
    const config = {
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
    }
    const browser = await chromium.puppeteer.launch(config)
    global.__BROWSER__ = browser
    await fs.mkdirs(DIR)
    await fs.writeFile(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint())
}
github iann0036 / amazon-connect-cfn / lambda / index.js View on Github external
return macro_response;
    } else {
        var response_object = {
            "Status": "SUCCESS",
            "PhysicalResourceId": event.LogicalResourceId,
            "StackId": event.StackId,
            "RequestId": event.RequestId,
            "LogicalResourceId": event.LogicalResourceId,
            "Data": {}
        };

        try {
            browser = await puppeteer.launch({
                args: chromium.args,
                defaultViewport: chromium.defaultViewport,
                executablePath: await chromium.executablePath,
                headless: chromium.headless,
            });

            let page = await browser.newPage();

            if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_Instance") {
                await login(page);
                response_object.Data = await createinstance(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_ContactFlow") {
                await login(page);
                await open(page, event.ResourceProperties);
                response_object.Data = await createflow(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_PhoneNumber") {
                await login(page);
                await open(page, event.ResourceProperties);

chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis