Katman
Plugins

Compression

Gzip/deflate response compression hints via a wrap middleware.

The compression wrap attaches encoding hints to the context for transport-level compression. Most useful with handler() and custom servers where you control response encoding.

Usage

import {  } from "katman/plugins"

const  = k.query({
  : [()],
  : ({  }) => .db.users.findMany(),
})

Options

OptionTypeDefaultDescription
thresholdnumber1024Minimum response size in bytes before compressing
encoding"gzip" | "deflate""gzip"Preferred encoding

Custom threshold

const  = compressionWrap({
  : 512,     // compress responses > 512 bytes
  : "deflate",
})

With serve(), Node.js handles compression at the HTTP level. This wrap is primarily for handler()-based deployments (Cloudflare Workers, Bun, Deno) where you manage response encoding yourself.

What's next?

  • Serverserve() and handler() options
  • Plugins — other available plugins

On this page