honojs-middleware/packages/bun-compress
Jonathan Haines 9235709060
refactor: composite build (#1230)
* refactor: composite build

* chore(ua-blocker): move demo.ts out of src
2025-06-16 11:23:47 +09:00
..
src feat(bun-compress): Created a compress middleware that supports Bun (#1153) 2025-05-13 07:15:11 +09:00
CHANGELOG.md Version Packages (#1158) 2025-05-13 07:26:50 +09:00
README.md feat(bun-compress): Created a compress middleware that supports Bun (#1153) 2025-05-13 07:15:11 +09:00
package.json Version Packages (#1158) 2025-05-13 07:26:50 +09:00
tsconfig.build.json refactor: composite build (#1230) 2025-06-16 11:23:47 +09:00
tsconfig.json refactor: composite build (#1230) 2025-06-16 11:23:47 +09:00
tsconfig.spec.json feat(bun-compress): Created a compress middleware that supports Bun (#1153) 2025-05-13 07:15:11 +09:00
vitest.config.ts test(bun-compress): fix vitest config (#1164) 2025-05-15 22:41:48 +09:00

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.