* refactor: composite build * chore(ua-blocker): move demo.ts out of src |
||
---|---|---|
.. | ||
src | ||
CHANGELOG.md | ||
README.md | ||
package.json | ||
tsconfig.build.json | ||
tsconfig.json | ||
tsconfig.spec.json | ||
vitest.config.ts |
README.md
Bun Compress Middleware for Hono
Bun does not currently support the CompressionStream API so this middleware replicates the behavior of hono/compress
using the Zlib library. This middleware will be deprecated once Bun adds support for CompressionStream
.
This middleware will use hono/compress
if CompressionStream is available so you can use this middleware in Bun and Node.js without any changes.
Import
import { Hono } from 'hono'
import { compress } from '@hono/bun-compress'
Usage
const app = new Hono()
app.use(compress())
Options
encoding: 'gzip'
| 'deflate'
The compression scheme to allow for response compression. Either gzip
or deflate
. If not defined, both are allowed and will be used based on the Accept-Encoding
header. gzip
is prioritized if this option is not provided and the client provides both in the Accept-Encoding
header.
threshold: number
The minimum size in bytes to compress. Defaults to 1024 bytes.