serverless-plugin-headless-chrome

0.0.0-pre-release-5 • Public • Published

Serverless-framework Headless Chrome Plugin

A Serverless-framework plugin which bundles the @serverless-chrome/lambda package and ensures that Headless Chrome is running when your function handler is invoked.

Contents

  1. Installation
  2. Setup
  3. Local Development
  4. Configuration

Installation

Install with yarn:

yarn add --dev serverless-plugin-headless-chrome

Install with npm:

npm install --save-dev serverless-plugin-headless-chrome

Requires Node 6.10 runtime.

Setup

Add the following plugin to your serverless.yml:

plugins:
  - serverless-plugin-headless-chrome

Then, in your handler code.. Do whatever you want. Chrome is running!

const CDP = require('chrome-remote-interface')
 
module.exports.hello = (event, context, callback, chrome) => {
  // Chrome is already running!
 
  CDP.Version()
    .then((versionInfo) => {
      callback(null, {
        statusCode: 200,
        body: JSON.stringify({
          versionInfo,
          chrome,
        }),
      })
    })
    .catch((error) => {
      callback(null, {
        statusCode: 500,
        body: JSON.stringify({
          error,
        }),
      })
    })
}

Configuration

todo: via custom variables you can pass chrome flags.

Local Development

Local development is supported. A locally installed version of Chrome will be launched.

Package Sidebar

Install

npm i serverless-plugin-headless-chrome

Weekly Downloads

1

Version

0.0.0-pre-release-5

License

MIT

Last publish

Collaborators

  • adieuadieu