0.1.2 • Published 7 months ago

@response/buffer v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Buffer Response

A class representing a raw response backed by a Buffer.

Installation

npm install @response/buffer

Usage

const buffer = require('@response/buffer')
const http = require('http')

const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==', 'base64')

http.createServer((req, res) => {
  // Status 200, type application/octet-stream
  buffer(png).write(res)

  // Status 200, type application/octet-stream
  buffer(200, png).write(res)

  // Status 200, type image/png
  buffer(200, png, { 'Content-Type': 'image/png' }).write(res)
})

Mutable Properties

  • statusCode: number - The status code
  • headers: object - The custom headers
  • data: Buffer - The raw data
0.1.2

7 months ago

0.1.1

4 years ago