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

docker-lambda-api-server

v1.0.3

Published

docker-lambda-api-server ------------------------

Downloads

16

Readme

docker-lambda-api-server

A companion tool for the awesome docker-lambda sandbox.

This is a very basic, local AWS Lambda API server that lets you invoke your lambda functions via the AWS SDK instead of running Docker from the command-line or docker-lambda Node helper.

It also leverages (although very limited at this point) the new AWS Cloudformation SAM template.

Prerequisites

Same as docker-lambda.

Installation

npm install docker-lambda-api-server

Example

Let's suppose you have 2 functions: hello and goodbye.

// hello.js
exports.handler = function(event, context, cb) {
  cb(null, JSON.stringify({hello: 'world'}))
}
// goodbye.js
exports.handler = function(event, context, cb) {
  cb(null, JSON.stringify({good: 'bye'}))
}

First thing you need to do (if you haven't already), is to create a SAM template like this:

# /greetings.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  SayHello:
    Type: AWS::Serverless::Function
    Properties:
      Handler: hello.handler
      Runtime: nodejs4.3
 
  SayGoodbye:
    Type: AWS::Serverless::Function
    Properties:
      Handler: goodbye.handler
      Runtime: nodejs4.3

As you can see above, we created the definition for our 2 functions, which we named SayHello and SayGoodbye, each one pointing to the right code file.

We are now ready to start the API server:

docker-lambda-api-server -f greetings.yml

An HTTP server will start listening at localhost:3000. You can do a quick test by invoking any of your functions via the AWS Lambda REST API:

curl http://localhost:3000/2015-03-31/functions/SayHello/invocations

{"hello":"world"}

Or you can also invoke the function via the AWS SDK:

import { Lambda } from 'aws-sdk'

let lambda = new Lambda({
  region: 'foo-west-1',
  endpoint: 'http://localhost:3000'
})

lambda
  .invoke({ FunctionName: 'SayGoodbye' })
  .promise()
  .then(result => console.log(result))

Documentation

// TODO

In the meanwhile, you can run

docker-lambda-api-server -h

to see all the options available.

You can also check out the provided example.

TODO

  • Unit tests?
  • Proper runtime validation (node, node4.3)
  • Implement ClientContext
  • Implement InvocationType
  • Implement Qualifier
  • Implement LogType
  • Implement environment variables in SAM template
  • Your suggestion here