@response/buffer
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @response/buffer

Weekly Downloads

12

Version

0.1.2

License

MIT

Unpacked Size

2.12 kB

Total Files

4

Last publish

Collaborators

  • linusu