npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

goldwasher-aws-lambda

v1.0.3

Published

A version of goldwasher that runs as a module on AWS Lambda.

Downloads

12

Readme

node-goldwasher-aws-lambda

npm version Build Status Coverage Status Code Climate

Dependency Status devDependency Status peerDependency Status

A version of goldwasher that runs as a module on AWS Lambda. Uses goldwasher-needle for requests.

Installation

This module installs as a module on AWS Lambda, as a zip file. You can either just download the zip from /dist and upload it via your AWS console or install it via aws-cli. The first one might not always work so the method with aws-cli described below is recommended:

npm install goldwasher-aws-lambda
cd node_modules/goldwasher-aws-lambda/dist/
aws lambda create-function --function-name goldwasher --timeout 60 --zip-file fileb://goldwasher-aws-lambda.zip

You can of course replace goldwasher with your name of choice and 60 with a lower timeout if necessary.

If you later need to overwrite it and the function name already exists on AWS, use this instead:

aws lambda update-function-code --function-name goldwasher --zip-file fileb://goldwasher-aws-lambda.zip

Options

The module accepts the usual parameters of goldwasher-needle with the exception that the url and options parameters have been merged. This simply means that the first parameter, url, has been removed and must instead be added as a property on the options parameter:

{
  url: 'http://github.com',
  goldwasher: {
    selector: 'h1'
  }
}

See how to use this in the examples below or simply paste it as a sample event in the AWS console.

Build

If you feel like changing the code and have installed the development dependencies, you can automatically build a new zip file from the main folder:

gulp zip

This will create a new zip that can be installed with the commands mentioned under installation.

Example

In this example we will show how to consume the Lambda function from a client. First, install the aws-sdk:

npm install aws-sdk

In this example, we will use a config file for our AWS credentials. Remember to replace the values below with your own.

IMPORTANT:

It is extremely important that you do not push this file to your git repository or any other public place. I highly recommend using environment variables instead. I also recommend creating a user on AWS that only has the permission AWSLambdaRole to run this.

aws-config.json:

{ 
	"accessKeyId": "akid",
	"secretAccessKey": "secret",
	"region": "us-east-1"
}

example.js:

var AWS = require('aws-sdk');

AWS.config.loadFromPath('./aws-config.json');

var lambda = new AWS.Lambda();

lambda.invoke({
	FunctionName: 'goldwasher',
	Payload: JSON.stringify({url: 'http://google.com'})
},
function(error, data) {
	if (error) {
		console.error(error);	
	}
	console.log(data);
});