middy-jsonapi (v2.0.2) is a middleware for the Middy Node.js AWS Lambda framework that formats Lambda responses to conform to the JSON API spec (jsonapi.org). It parses query parameters like include, fields, sort, and page, supports page-based and offset-based pagination with auto-generated links, and formats errors into standard JSON API error objects. Unlike manual formatting, it integrates seamlessly with Middy's middleware chain (e.g., validator, httpContentNegotiation) and works with strict Accept headers (application/vnd.api+json). Requires middy as a peer dependency. Active development, release cadence irregular.
npm install middy-jsonapiVerified import paths — ran on the pinned version, not inferred.
Shows how to import, configure, and use middy-jsonapi with a basic handler and optional response metadata.
Use import jsonapi from 'middy-jsonapi' or use dynamic import().
Ensure httpContentNegotiation or a custom middleware sets the Accept header to the required media type.
Consider using an alternative caching mechanism or check compatibility.
Run npm install middy-jsonapi and ensure you use import (ESM) not require().
Use import jsonapi from 'middy-jsonapi' without curly braces.