npm package: @lambda-lambda-lambda/router
Description: AWS CloudFront Lambda@Edge serverless application router.
Author: Marc S. Brooks
Latest version: 0.8.8

# L³ router

[![npm version](https://badge.fury.io/js/@lambda-lambda-lambda%2Frouter.svg)](https://badge.fury.io/js/@lambda-lambda-lambda%2Frouter) [![](https://img.shields.io/npm/dm/@lambda-lambda-lambda/router.svg)](https://www.npmjs.com/package/@lambda-lambda-lambda/router) [![Build Status](https://img.shields.io/github/actions/workflow/status/lambda-lambda-lambda/router/.github%2Fworkflows%2Fci.yml)](https://github.com/lambda-lambda-lambda/router/actions) [![Coverage](https://coveralls.io/repos/lambda-lambda-lambda/router/badge.svg?branch=master)](https://coveralls.io/r/lambda-lambda-lambda/router?branch=master) [![Install size](https://packagephobia.com/badge?p=@lambda-lambda-lambda/router)](https://packagephobia.com/result?p=@lambda-lambda-lambda/router) [![NO AI](https://raw.githubusercontent.com/nuxy/no-ai-badge/master/badge.svg)](https://github.com/nuxy/no-ai-badge)

AWS [CloudFront Lambda@Edge](https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html) serverless application router.

![lambda-lambda-lambda](https://raw.githubusercontent.com/lambda-lambda-lambda/router/master/package.png)

## Features

- Request/Response handling [API](https://github.com/lambda-lambda-lambda/manual/blob/master/CommonMethods.md).
- [Routes](https://github.com/lambda-lambda-lambda/manual/blob/master/ComplexRouting.md#route-handler) and URI [Resource](https://github.com/lambda-lambda-lambda/manual/blob/master/ComplexRouting.md#resource-handler) support.
- Local/Globally scoped [Middleware](https://github.com/lambda-lambda-lambda/manual/blob/master/Middleware.md#scope).
- [Visual Studio Code](https://code.visualstudio.com) integration.
- Open Source, [MIT licensed](https://github.com/lambda-lambda-lambda/router/blob/master/LICENSE), FREE.
- Lightweight (**no dependencies**).

## How does it work?

In its most basic form the library provides helper methods that translate the [CloudFront Lambda@Edge](https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html) `origin-request` allowing you to handle response processing **without the need to construct complex Lambda dependent responses**.

To better visualize how L³ fits in the current AWS ecosystem the following high-level graph describes the _HTTP Request/Response lifecycle_ and role of each AWS provided service.

![HTTP Request/Response lifecycle](https://raw.githubusercontent.com/lambda-lambda-lambda/manual/master/images/Request-Response-Lifecycle.png)

## Getting started

The easiest way to created an application, without the need to [manually install](#manual-installation) this package, is to use the [L³ Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=Nuxy.vscode-lambda-lambda-lambda). Doing so allows you to..

- Scaffold app sources and dependencies.
- Run it locally (in [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers))
- Test code changes in realtime.
- Deploy app sources to AWS.
- Generate [JSDoc](https://jsdoc.app)/[Swagger](https://swagger.io) documentation.

## Build dependencies

If you're not using the [L³ VS Code extension](https://marketplace.visualstudio.com/items?itemName=Nuxy.vscode-lambda-lambda-lambda) and want to _run this package locally_ you must install the following dependencies:

- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
- [Node.js](https://nodejs.org)

## Manual installation

If you just looking to leverage the Request/Response handling [API](CommonMethods.md) in your Lambda functions, install this package using [NPM](https://npmjs.com).

    $ npm install @lambda-lambda-lambda/router

## Documentation

- [Introduction](https://github.com/lambda-lambda-lambda/manual/blob/master/Introduction.md)
- [Getting Started](https://github.com/lambda-lambda-lambda/manual/blob/master/GettingStarted.md)
- [AWS requirements](https://github.com/lambda-lambda-lambda/manual/blob/master/AWSRequirements.md)
- [Running your App](https://github.com/lambda-lambda-lambda/manual/blob/master/RunningYourApp.md)
- [Usage](https://github.com/lambda-lambda-lambda/manual/blob/master/Usage.md)
- [Common methods](https://github.com/lambda-lambda-lambda/manual/blob/master/CommonMethods.md)
- [Complex routing](https://github.com/lambda-lambda-lambda/manual/blob/master/ComplexRouting.md)
- [Middleware](https://github.com/lambda-lambda-lambda/manual/blob/master/Middleware.md)
- [Developers](https://github.com/lambda-lambda-lambda/manual/blob/master/Developers.md)
- [Testing](https://github.com/lambda-lambda-lambda/manual/blob/master/Testing.md)

## AWS changes starting in Node.js 24 (CloudWatch warning)

Going forward, it is recommended that you build your L³ application using `async` handlers in anticipation of the AWS changes below.

> AWS Lambda plans to remove support for callback-based function handlers starting with Node.js 24. You will need to update this function to use an async handler to use Node.js 24 or later. For more information and to provide feedback on this change, see aws/aws-lambda-nodejs-runtime-interface-client#137

While backwards compatibity will be supported for older Node.js releases this support **will eventually be phased out** with the deprecation of `nodejs22.x` (Apr 30, 2027).

See [AWS Node.js Supported Runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported) for support information.

## Versioning

This package is maintained under the [Semantic Versioning](https://semver.org) guidelines.

## License and Warranty

This package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

_lambda-lambda-lambda/router_ is provided under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.php)

[AWS](https://aws.amazon.com) is a registered trademark of Amazon Web Services, Inc.

## Author

[Marc S. Brooks](https://github.com/nuxy)