bragg-env is a middleware for the `bragg` serverless framework, designed to automatically extract and expose environment information within the request context (`ctx.env`) for AWS Lambda functions. It leverages the `aws-lambda-env` package to intelligently determine the runtime environment, providing sensible defaults such as `development` when running in `$LATEST` Lambda versions and `production` for other deployed versions. This behavior can be explicitly overridden by setting the `NODE_ENV` environment variable. The package's current stable version is 2.0.0, released approximately four years ago, indicating a mature but inactive state. Both `bragg-env` and its foundational `bragg` framework show no recent development activity or releases, suggesting the package is now abandoned. Its primary utility lies in simplifying environment configuration within the `bragg` ecosystem, abstracting away the specifics of AWS Lambda environment detection, but it lacks modern features and active community support that newer serverless frameworks might offer.
npm install bragg-envVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `bragg-env` middleware into a `bragg` application to expose the detected environment on the context object.
Consider migrating to actively maintained serverless frameworks and their respective environment management solutions for new projects. For existing projects, proceed with caution and thorough security audits.
There is no direct fix for this within `bragg-env`. If you must use this package, you might be forced to use older Node.js runtimes, which comes with its own security and maintenance risks. It's strongly recommended to avoid this package in environments requiring modern Node.js versions.
Always use `const environment = require('bragg-env');` for importing this package. If your project is ESM-first, you might need to use dynamic `import()` or review your build configuration to accommodate CommonJS modules, or consider alternatives.Ensure `bragg` is installed: `npm install bragg`. If using a monorepo, verify that `bragg` is resolvable from the `bragg-env` context.
Ensure `app` is initialized as `const app = require('bragg')();` before calling `app.use()`.Verify that `process.env.NODE_ENV` is set *before* the `bragg-env` middleware is initialized. If running in AWS Lambda, ensure `NODE_ENV` is configured in the Lambda function's environment variables. Review the `options` object passed to `environment()` to confirm `default` or other keys are not unintentionally preventing `NODE_ENV` from taking precedence.