honojs-middleware/packages/bun-compress
Nick Dobie 3fe5cb4d5e feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
..
src feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
README.md feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
package.json feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
tsconfig.build.json feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
tsconfig.json feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
tsconfig.spec.json feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00
vitest.config.ts feat(bun-compress): Created a compress middlware that supports Bun 2025-05-07 21:52:49 -05:00

README.md

Bun Compress Middleware for Hono

Bun does not currently support the CompressionStream API so this middlware replicates the behavor of hono/compress using the Zlib library. This middleware will be depreacted 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.