Lambda API: v0.2.0 released

Posted in #lambda-api

I've been banging away at some features for Lambda API as I discover new use cases in production. This new release adds two new convenience methods: location() and redirect(). These are great for shortcutting redirects without needing to manually specify the headers. I also cleaned up the code a bit and removed some inconsistent whitespace.  👨🏻‍💻🎉

Plus I created a fancy new logo a few days ago! See what I did there? I like it. 🤘🏻

Introducing Namespaces! 🚀

Lambda API now allows you to map specific modules to namespaces that can be accessed from the REQUEST object. This is helpful when using the pattern in which you create a module that exports middleware, error, or route functions.

In the example below, the data namespace is added to the API and then accessed by reference within an included module:

// Use app() function to add 'data' namespace'data',require('./lib/data.js')) // Create a get route to load user details api.get('/users/:userId', require('./lib/users.js'))

The users.js module might look like this:

module.exports = function(req, res) { let userInfo = res.json({ 'userInfo': userInfo }) });

By saving references in namespaces, you can access them without needing to require them in every module. Namespaces can be added using the app() method of the API. app() accepts either two parameters: a string representing the name of the namespace and a function reference OR an object with string names as keys and function references as the values.

For example:

// As a namespace/function reference combo'namespace1',require('./lib/ns1-functions.js')) // As an object{ 'namespace1': require('./lib/ns1-functions.js'), 'namespace2': require('./lib/ns2-functions.js') })

I find this feature super useful for passing around data references and utility functions! Let me know what you think.

Release Notes

Feature Release

v0.2.0 of Lambda API adds a few new convenience methods and introduces NAMESPACES, a new feature that lets you pass module references through the REQUEST object. See the documentation for examples.


  • Add location() and redirect() convenience methods 8b9a746
  • Add namespaces 1a37cd7
  • Add util functions escapeHtml and encodeUrl 72c6380

Documentation and Tests:

  • Add tests for new location() and redirect() methods e5cafd4
  • Add namespace documentation and other minor adjustments 3352c29
  • Update documentation with new methods 2dfdb10, 7e1f6bf
  • Add slow() setting for promise tests 8f1cc3a


Full Release Notes:

Comments are currently disabled, but they'll be back soon.