Socket
Socket
Sign inDemoInstall

shot

Package Overview
Dependencies
5
Maintainers
5
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    shot

Injects a fake HTTP request/response into a node HTTP server


Version published
Weekly downloads
51K
increased by23.87%
Maintainers
5
Install size
348 kB
Created
Weekly downloads
 

Readme

Source

shot Logo

Injects a fake HTTP request/response into a node HTTP server for simulating server logic, writing tests, or debugging. Does not use a socket connection so can be run against an inactive server (server not in listen mode).

Build Status

Lead Maintainer: Matt Harrison

Example

// Load modules

const Http = require('http');
const Shot = require('shot');


// Declare internals

const internals = {};


internals.main = async function () {

    const dispatch = function (req, res) {

        const reply = 'Hello World';
        res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length });
        res.end(reply);
    };

    const server = Http.createServer(dispatch);

    const res = await Shot.inject(dispatch, { method: 'get', url: '/' });
    console.log(res.payload);
};


internals.main();

Note how server.listen is never called.

API

See the API Reference

Keywords

FAQs

Last updated on 03 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc