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

dev-lambda

v0.1.1

Published

Provide AWS Lambda like functionality for local development purposes.

Downloads

35

Readme

dev-lambda

Provide AWS Lambda like functionality for local Node.js development purposes.

Purpose

Developing AWS lambda's isn't very hard but it would be nice to be able to serve them locally for rapidly testing changes, offline development, and intergration testing.

The System

  • each lambda should be its own directory
  • a parent directory contains all the lambdas to be served
  • dev-lambdaprovides a simple REST API communicating in JSON
  • the API can be used to list all available lambdas, simple metrics, and recent history of the output of each lambda
  • the API can be used to pass event data and initiate lambdas
  • the API provides a sync endpoint for each lambda for easier debugging

Getting Started

First copy the example lambda directory into the lambdas directory so we have something to see once the server is up.

Clone and Get Dependencies

git clone https://github.com/CoursePark/dev-lambda.git
cd dev-lambda
npm install

Use Example Worker

cp -r example-lambda lambdas/

Now we can kick off the server with Node.js, later we will do the same with a dockerizered version.

Straight Node.js

node lib/daemon.js

Now visit http://127.0.0.1:9961/ in your browser and you should see JSON saying something like:

{"example-lambda":{"config":{"name":"example-lambda","dirPath":"/Users/me/dev-lambda/lambdas/example-lambda","handler":"index.handler","maxMemory":128,"timeout":3}}}

So great, we can see that the example example-lambda is set up and ready. Lets run it, this is done by POSTing to http://127.0.0.1:9961/example-lambda.

using curl:

curl -X POST http://127.0.0.1:9961/example-lambda

or use something like the excellent Chrome App Postman

and should get something like, look for the Hello World!:

{"metrics":{"counts":{"total":1,"started":0,"done":1},"averageDuration":103},"history":[{"status":"done","started":"2015-11-18 04:53:46.165","updated":"2015-11-18 04:53:46.268","output":["2015-11-18 04:53:46.264: Hello World!\n","2015-11-18 04:53:46.265: event {}\n"],"completed":"2015-11-18 04:53:46.268","duration":103}],"config":{"name":"example-lambda","dirPath":"/Users/me/dev-lambda/lambdas/example-lambda","handler":"index.handler","maxMemory":128,"timeout":3}}

Now we just need the ability to pass event data into the lambda. This is accomplished by POSTing JSON as a request body and having a Content-Type: application/json header.

curl -H "Content-Type: application/json" -X POST -d '{"abc":"123"}' http://127.0.0.1:9961/sync/example-lambda

results in something like:

{"metrics":{"counts":{"total":2,"started":0,"done":2},"averageDuration":105},"history":[{"status":"done","started":"2015-11-18 05:02:39.006","updated":"2015-11-18 05:02:39.109","output":["2015-11-18 05:02:39.105: Hello World!\n","2015-11-18 05:02:39.107: event { abc: '123' }\n"],"completed":"2015-11-18 05:02:39.109","duration":103},{"status":"done","started":"2015-11-18 05:01:56.730","updated":"2015-11-18 05:01:56.837","output":["2015-11-18 05:01:56.833: Hello World!\n","2015-11-18 05:01:56.834: event {}\n"],"completed":"2015-11-18 05:01:56.837","duration":107}],"config":{"name":"example-lambda","dirPath":"/Users/me/dev-lambda/lambdas/example-lambda","handler":"index.handler","maxMemory":128,"timeout":3}}

Using Docker

docker build -t dev-lambda .
docker run -ti -p 9961:9961 -v /Users/me/my-lambdas/:/usr/src/app/lambdas dev-lambda