Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @middy/http-partial-response with all npm packages installed. Try it out:

require("@middy/core/package.json"); // @middy/core is a peer dependency. var httpPartialResponse = require("@middy/http-partial-response")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@middy/http-partial-response v1.1.0

Http partial response middleware for the middy framework

Middy http-partial-response middleware

Middy logo

HTTP partial response middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

Filtering the data returned in an object or JSON stringified response has never been so easy. Add the httpPartialResponse middleware to your middleware chain, specify a custom filteringKeyName if you want to and that's it. Any consumer of your API will be able to filter your JSON response by adding a querystring key with the fields to filter such as fields=firstname,lastname.

This middleware is based on the awesome json-mask package written by Yuriy Nemtsov


To install this middleware you can use NPM:

npm install --save @middy/http-partial-response


This middleware does not have any option

Sample usage

const middy = require('@middy/core')
const httpPartialResponse = require('@middy/http-partial-response')

const handler = middy((event, context, cb) => {
  const response = {
    statusCode: 200,
    body: {
      firstname: 'John',
      lastname: 'Doe',
      gender: 'male',
      age: 30,
      address: {
        street: 'Avenue des Champs-Élysées',
        city: 'Paris'

  cb(null, response)


const event = {
  queryStringParameters: {
    fields: 'firstname,lastname'

handler(event, {}, (_, response) => {
    firstname: 'John',
    lastname: 'Doe'

Middy documentation and examples

For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.


Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.


Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.

FOSSA Status

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free