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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ffleet/shim

v1.5.0

Published

AWS Lambda Node.js Shim

Readme

AWS Lambda Shim

CircleCI npm

A Better Lambda API

This library provides an abstraction between the AWS Lambda events and classic node.js calling conventions.

This project is sponsored by the Functional Fleet Serverless Platform. We are currently accepting beta users for our platform, featuring a free git repo, hosted deploy queue, and centralized monitoring.

Why

AWS Lambda has a somewhat unintuitive API structure that is sometimes inconsistent with node.js standards. This library bridges the gap, allowing you to write more familiar node.js style code.

Wrap

Wrapping your function standardizes the calling conventions across all versions of Node.js and all AWS Lambda event sources. This includes:

  • Supporting Promise returns, rather than the callback argument
  • Standardizing arguments to (event, callback)
  • Providing additional helpers through the this object

Example:

var shim = require('@ffleet/shim');
var myLib = require('./lib');

// callback is not needed with Promise
function myHandler(event) {
	// myLib.handle returns a promise
	return myLib.handle(event);
}

exports.myHandler = shim.wrap(myHandler);

Libraries

The specific API shims below provide context specific APIs for certain Lambda events.

HTTP

Node.js HTTP servers are built around request and response objects passing through route handlers. This has been embraced by the common node.js HTTP libraries as well (Express, Hapi, Restify, etc.).

The http shim creates a native node.js HTTP server and proxies the AWS Lambda event.

For example, using a native handler:

const shim = require('@ffleet/shim');

function myNativeHttpHandler(req, res) {
	res.end('Hello, World!');
}

exports.myNativeHttpHandler = shim.http(myNativeHttpHandler);

Or, you can wrap an entire Express server:

const shim = require('@ffleet/shim');
const express = require('express');
const app = express();

app.get('/', function(req, res, next) {
	res.send('Hello, World!');
});

exports.myExpressHttpHandler = shim.http(app);

Cron

Cron functions are executed by AWS CloudWatch Events. Wrapping with the cron shim unpacks the event data and provides a Date object of when the cron event was generated.

const shim = require('@ffleet/shim');

function myCron(date, callback) {
	console.log('cron event generated at ' + date.toISOString());
}
exports.myCron = shim.cron(myCron);

Logs

AWS CloudWatch Log data is provided in a base64 encoded and gzip packed data string. The logs shim will decode the log data and reconstitute the represented JSON object, as:

{
	"messageType": "DATA_MESSAGE",
	"owner": "123456789123",
	"logGroup": "testLogGroup",
	"logStream": "testLogStream",
	"subscriptionFilters": ["testFilter"],
	"logEvents": [{
		"id": "eventId1",
		"timestamp": 1440442987000,
		"message": "[ERROR] First test message"
	}, {
		"id": "eventId2",
		"timestamp": 1440442987001,
		"message": "[ERROR] Second test message"
	}]
}

Example:

const shim = require('@ffleet/shim');

function myLogHandler(logObject, callback) {
	logObject.logEvents.forEach(logEvent => console.log('log', logEvent));
}
exports.myLogHandler = shim.logs(myLogHandler);

License

MIT License

Copyright (c) 2018 Functional Fleet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.