Nimoy Prospers Mystically

    @foxify/inject
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    inject

    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).

    NPM Version Node Version TypeScript Version Tested With Jest Pull Requests License Build Status Coverage Status Package Quality Dependencies Status NPM Total Downloads NPM Monthly Downloads Open Issues Closed Issues known vulnerabilities Github Stars Github Forks

    Example

    const http = require('http')
    const inject = require('@foxify/inject').default
    
    const dispatch = function (req, res) {
      const reply = 'Hello World'
      res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length })
      res.end(reply)
    }
    
    // Nah, you don't need this anymore :)
    // const server = http.createServer(dispatch)
    
    inject(dispatch, { method: 'get', url: '/' }, (err, res) => {
      console.log(res.body)
    })

    Install

    npm i @foxify/inject

    DownloadsWeekly Downloads

    19

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    17.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • ardalanamini