0.0.2 • Published 7 years ago

http-interfaces v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

http-interfaces

CircleCI Build Status

Usage

WIP: usage example coming

This module creates mock incomingMessage and serverResponse interfaces - although it's still very much a WIP it's designed to allow testing of functions that interact with the http or https or http\2 ServerResponse and IncomingMessage like interfaces by exposing mocks for them that also implement a set of features from the HTML5 Fetch interface.

The basic idea is that you can create an IncomingMessage instance using the same parameters that you'd pass to fetch on the client side, as well and read data from a generated ServerResponse instance using the same API that you'd use to interface with an HTML 5 Response instance.

API

WIP: documentation is not complete

createServerResponse()

Returns a serverResponse (object && stream.Writable) - a ServerResponse-ish and HTML5 Response-ish instance.

serverResponse (presently implemented methods and properties)

  • write()
  • end()
  • writeHead()
  • setHeader()
  • getHeader()
  • statusCode
  • statusMessage

  • buffer() used instead of .blob()

  • status
  • statusText
  • ok

createIncomingMessage(/fetch-ish parameters/)

incomingMessage

  • read()
  • pipe()
  • method
  • url

Returns an incomingMessage (object && stream.Readable) a IncomingMessage-ish and HTML5 Response-ish instance)**

LICENSE

© axdg (axdg@dfant.asia) 2017

0.0.2

7 years ago

0.0.1

7 years ago