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

bty

v1.0.0-alpha.1

Published

Simple command line utility for developing and deploying AWS Lambda functions.

Downloads

4

Readme

betty

Simple command line utility for developing and deploying AWS Lambda functions.

Why? Because webpack wasn't cutting it:

Size matters

Webpack regularly put out 10MB bundles. Rollup does magic, and reduces that down to just what's needed. Like god intended.

Installing

npm install bty

Prerequisites

  • Create an IAM role for your lambda function
  • Make sure you have AWS_PROFILE or equivilent required env variables set so aws-sdk can pick them up
  • Create a project.json file as described below (based on the apex file)

Getting started

Creating a sample project

mkdir my-project && cd my-project
echo '{}' > project.json
echo '{ "name": "test-betty-function", "role":  }'
npm install cmawhoter/betty --save-dev
mkdir dist
echo 'exports.handler = function(event, context, callback) { callback(null, "hello " + Date.now()); };' > dist/index.js

Running betty

All commands should be from project root.

Serving locally

You can serve your lambda function locally as an emulated API Gateway proxied function.

betty serve
Server running at:  http://localhost:3000

Open http://localhost:3000 up in a browser and the console will output hello 1234567890. (Note: There will be an error too because our function isn't returning a properly formatted API Gateway response.)

Update AWS

Bundles the contents of dist/ into a zip file suitable for lambda and creates/updates the remote function.

betty update --region us-west-2

Alternatively, you can run the following to just create the zip and exit without making any calls to aws lambda:

betty update --test

project.json

{
  "name": "some-function-name",
  "description": "the description displayed with the function in aws lambda",
  "runtime": "nodejs4.3",
  "memory": 512,
  "timeout": 25,
  // can be a full 'arn:' path or relative role
  "role": "ulp_lambda_function", 
  // the local entry point for the function.  depending on if you're using
  // a build tool or not, this may be different than the source files
  "main": "dist/index.js",
  // the lambda entry point.  (this is what you'd manually type into lambda)
  "entry": "index.handler",
  // can either be a key/string object or a javascript string
  // *** 
  // don't store secrets here.  store them 
  // in separate file not in git.
  // see below for strategy
  // ***
  "environment": { "some": "env variable" }
}

project.environment

If project.environment is a string, it'll be eval'd and the result populate environment.

This allows you to do this for staged env vars.

  "environment": "load(`env-${process.env.NODE_ENV}.json`)"

Because require is relative to the source file it can't be used. load() basically does the same thing so you don't have to JSON.parse(fs.read blah blah.