New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hammock

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hammock

Node.js mock / polyfill http object library for http req / res

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

hammock

Node.js mock / polyfill http object library for http req / res.

Motivation

Polyfill req / res for testing w/o http or for code generation from an existing site.

Example

/* Should consider migrating to a factory so that people don't have to guess whether to use new or not */
var MockRequest = require('hammock').Request,
    MockResponse = require('hammock').Response;

/* Most This is most helpful for GET requests.  In future, it would be nice to polyfill body parsing events. */
var req = new MockRequest({
        url: '/foo',
        headers: { host: 'localhost', bar: 'baz' },
        method: 'GET'
    }),
    res = new MockResponse();

res.on('end', function(err, data) {
     console.log(data.statusCode);
     console.log(util.inspect(data.headers));
     console.log(data.body);
});

/* Using pipeline-router / director syntax here, but this should be simple with express. */
var router = RouterFactory.create({ /* options */ });
router.dispatch(req, res);

Keywords

FAQs

Package last updated on 24 Sep 2016

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