compress responses middleware for toa.
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)
npm install toa-compress
const compress = require('toa-compress')
options.threshold
:Number
, Default1024
, the threshold length that should compress.
app.use(compress({threshold: 1024}))
(The MIT License)