Bragg is a concise AWS Lambda web framework that provides a Koa.js-inspired middleware pattern for handling serverless HTTP requests. It simplifies the process of building API Gateway-backed Lambda functions by allowing developers to chain middleware functions that operate on a `ctx` (context) object. As of its current stable version, 1.4.0, Bragg maintains a focused scope, emphasizing a clear request-response cycle and robust error handling through its `app.onError()` mechanism, which supports asynchronous cleanup processes. Its release cadence appears stable rather than rapid, indicating a mature project. A key differentiator is its straightforward approach to promise resolution for `ctx.body`, automatically awaiting results before sending the Lambda response. It requires Node.js version 4 or higher.
npm install braggVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize Bragg, add a basic middleware to set the response body, configure an error handler, and export the resulting function for AWS Lambda.
Review `onError` implementations when upgrading to v1.4.0+ to ensure desired error propagation behavior. If you want errors to be caught by Lambda's runtime, you can now simply `throw err;` within `onError`.
Add the provided mapping template (or a similar one) to your API Gateway Integration Request settings, ensuring the Lambda function receives the correct event structure. Refer to the 'Mapping template' section in the Bragg README.
Always use `const bragg = require('bragg');` when integrating Bragg into your Node.js Lambda functions, unless you are specifically using a build process that handles CJS-ESM interop.Ensure `const bragg = require('bragg');` is present at the top of your file.Verify that your API Gateway Integration Request has a mapping template configured to pass parameters, query strings, and the body to your Lambda function's event payload, as described in the Bragg documentation.
Ensure your Lambda function's entry point (`index.js` or similar) contains `exports.handler = app.listen();`.
Ensure `const app = bragg();` is called before attempting to use `app.listen()`.
No dependency data recorded yet.