Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

toajs/toa-compress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toa-compress

compress responses middleware for toa.

NPM version Build Status Downloads

Demo

const Toa = require('toa')
const compress = require('../')

const app = new Toa()
app.use(compress())
app.use(function () {
  this.body = require('../package.json')
})

app.listen(3000)

compress stream:

const fs = require('fs')
const path = require('path')
const Toa = require('toa')
const compress = require('../')

const app = new Toa()
app.use(compress())
app.use(function () {
  this.body = fs.createReadStream(path.resolve(__dirname, '../package.json'))
  this.type = 'json'
})

app.listen(3000)

Installation

npm install toa-compress

API

const compress = require('toa-compress')

app.use(compress([options]))

  • options.threshold: Number, Default 1024, the threshold length that should compress.
app.use(compress({threshold: 1024}))

Licences

(The MIT License)

About

Compress responses middleware for toa.

Resources

License

Stars

Watchers

Forks

Packages

No packages published