Socket
Socket
Sign inDemoInstall

tamper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tamper

middleware to capture and modify response bodies


Version published
Weekly downloads
2.6K
decreased by-12.5%
Maintainers
1
Weekly downloads
 
Created
Source

tamper

Node.js middleware to capture and modify response bodies

Build Status

Installation

npm install tamper

Usage

var tamper = require('tamper');

app.use(tamper(function(req, res) {

  // Look at the request or the response headers and decide what to do.

  // In this case we only want to modify html responses:
  if (res.getHeader('Content-Type') != 'text/html') {

    // When returning a falsy value processing will continue as usual
    // without any performance impact.
    return;
  }

  // Return a function in order to capture and modify the response body:
  return function(body) {
    // The function may either return a Promise or a string
    return body.replace(/foo/g, 'bar');
  };

});

License

MIT

Keywords

FAQs

Package last updated on 11 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc