Registry / aws / middy-autoproxyresponse

middy-autoproxyresponse

JSON →
library0.1.0jsnpmunverified

The `middy-autoproxyresponse` middleware was designed to simplify AWS Lambda proxy responses by automatically wrapping plain JavaScript objects returned from a handler into a `statusCode: 200` response with `Content-Type: application/json`. If a `statusCode` is already present in the returned object, it passes through untouched. The package is currently at version 0.1.0, released in 2018. Given the rapid evolution and numerous breaking changes in the core `middy` framework (which is now in its 7.x series, released frequently), this middleware is highly likely incompatible with modern `middy` versions (v2.x and above), especially since `middy` v5+ is ESM-only. It provides a basic utility that is often reimplemented or achieved with other, more actively maintained `middy` middlewares like `@middy/http-response-serializer` for newer versions.

npm install middy-autoproxyresponse
INSTALL
IMPORT
SIG · MIDDY-AUTOPROXYRES
M
middy-autoproxyresponse
awsjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

autoProxyResponse
import { autoProxyResponse } from 'middy-autoproxyresponse'
const { autoProxyResponse } = require('middy-autoproxyresponse')
While the README shows ESM import, this old package (v0.1.0) likely ships as CommonJS. Newer Middy (v5+) is ESM-only, leading to potential module resolution issues if used with modern Middy.
middy
import middy from '@middy/core'
const middy = require('middy')
The core `middy` package itself changed import paths and module types significantly. Since `middy` v2.x, core components are typically imported from `@middy/core`. Since v5.x, Middy is ESM-only.

Demonstrates defining a simple Lambda handler that returns a plain object, which `autoProxyResponse` then converts into a standard API Gateway proxy response.

import middy from '@middy/core'; import { autoProxyResponse } from 'middy-autoproxyresponse'; interface MyEvent { name?: string; } interface MyContext extends Record<string, any> {} async function handler(event: MyEvent, context: MyContext) { // Simulate some async operation await new Promise(resolve => setTimeout(resolve, 100)); if (event.name) { return { message: `Hello, ${event.name}!` }; } else { // This will be converted to a 200 OK JSON response by autoProxyResponse return { greeting: 'Hello, world!' }; } } export const wrappedHandler = middy(handler) .use(autoProxyResponse()); // To simulate execution (e.g., for local testing) // wrappedHandler({ name: 'Registry' }, {} as MyContext) // .then(res => console.log('Response:', JSON.stringify(res, null, 2)));
Debug
Known issues
breakingThis middleware (v0.1.0) was developed for an older version of the `middy` framework (likely v0.x or v1.x). It is highly unlikely to be compatible with `middy` v2.x, v3.x, v4.x, or newer due to significant internal breaking changes in `middy`'s core API and middleware lifecycle.
fix
Consider using the actively maintained `@middy/http-response-serializer` (or similar core middy middlewares) for modern Middy versions, or implementing the response transformation manually.
affects: >=2.0.0
breakingThe `middy` framework, starting from v5.0.0, is ESM-only (ECMAScript Modules). This `middy-autoproxyresponse` package (v0.1.0) is a CommonJS module. Using a CommonJS middleware with an ESM-only core framework will result in module resolution errors unless specific build configurations are applied (which is not officially supported or recommended).
fix
Avoid using this middleware with `middy` v5.0.0 or later. Migrate to `middy`'s native HTTP response handling or use a modern, ESM-compatible alternative.
affects: >=5.0.0
deprecatedThe functionality provided by `middy-autoproxyresponse` (converting plain objects to API Gateway proxy responses) is now commonly handled by official `middy` core middlewares like `@middy/http-response-serializer` which offer more robust and configurable options.
fix
For new projects or migrations, prefer `@middy/http-response-serializer` or similar from the official `@middy` ecosystem.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to `import` a CommonJS module in an ESM context, or vice-versa, which is common when mixing older middleware with newer `middy` versions or Node.js runtimes.
fix
This specific middleware is CommonJS. If you are using a recent version of `middy` (v5.x+) which is ESM-only, `middy-autoproxyresponse` is fundamentally incompatible. Downgrade `middy` to a compatible version (v0.x or v1.x) or replace this middleware with an ESM-compatible alternative.
TypeError: handler.use is not a function
Attempting to use `middy-autoproxyresponse` with an incompatible `middy` core version, where the `middy()` wrapper might have changed its API or is not correctly imported.
fix
Ensure that the `middy` core package version is compatible with this middleware (likely `middy@^0.x` or `middy@^1.x`). Given this middleware's age, it's safer to use an actively maintained middleware for current `middy` versions.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
middyrequiredThis is a middleware for the Middy.js framework. Likely only compatible with Middy v0.x or v1.x.
Agent activity
16 hits · last 30 days
node
14
Resources
middy-autoproxyresponse — npm install middy-autoproxyresponse · libregistry