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

lambda-deploy

v2.1.0

Published

Deploy lambda functions

Downloads

3

Readme

Build Status Dependency Status devDependency Status

Lambda deploy

Workflow

  • build project into zip bundle
  • upload bundle to S3
  • create/update the lambda function

If the lambda function does not exist, the script creates it. However, it does not configure event sources and other parameters. Manual intervention is therefore required.

Conventions to follow

Source code compilation

Source code goes into src/. Source code is compiled by babel. The function entry point is the handler function exported in src/index.js. Dependencies must be listed in package.json.

Build configuration

The following environment variables are needed to deploy the function:

  • AWS_SECRET_ACCESS_KEY
  • AWS_ACCESS_KEY_ID
  • AWS_DEFAULT_REGION
  • S3_BUCKET
  • LAMBDA_NAME
  • LAMBDA_ROLE_ARN
  • GIT_BRANCH, equivalently TRAVIS_BRANCH
  • GIT_COMMIT, equivalently TRAVIS_COMMIT
  • GIT_PULL_REQUEST, equivalently TRAVIS_PULL_REQUEST (optional)
  • GIT_TAG, equivalently TRAVIS_TAG (optional)

WARNING: the value of those variables must be kept secret. If using Travis, do not set them in the .travis.yml config file, only in the Travis project's settings (where they are kept secret).

Runtime configuration

To pass runtime configurations to the function, set environment variables prefixed by __FUNC_CONFIG__. Those will be collected and written to the .env file from where they can be loaded using dotenv.

For example, if we define the following environment variables in the build environment:

env DB_HOST=localhost
env DB_USER=root
env DB_PASS=s1mpl3

then the following .env file is generated:

DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3

which can be loaded by the lambda function with:

import {load} from "dotenv";
load();

export function handler (event, context) {
    context.succeed(JSON.stringify(process.env));
}

Output

The script bundles the current repository and uploads it to AWS S3. The name of the bundle is derived from the following parameters:

  • LAMBDA_NAME
  • GIT_BRANCH
  • GIT_COMMIT
  • GIT_TAG
  • GIT_PULL_REQUEST

The name of the lambda function is derived from the following parameters:

  • LAMBDA_NAME
  • GIT_BRANCH