Plugins
Compression
Standard-compliant response compression for high-performance delivery.
The @axeom/compression plugin utilizes the native Web CompressionStream API to efficiently compress outgoing responses based on the client's Accept-Encoding header.
Installation
npm install @axeom/compressionUsage
import Axeom from '@axeom/framework';
import { compression } from '@axeom/compression';
const app = new Axeom()
.use(compression({
threshold: 1024 // Only compress responses larger than 1KB
}));Features
- Standard Compliant: Uses the standard
CompressionStreamAPI (supported in Bun, Deno, and Node 18+). - Format Support: Automatically negotiates Gzip and Deflate compression.
- Intelligent Skipping:
- Automatically ignores responses that already have a
Content-Encodingheader. - Skips Server-Sent Events (
text/event-stream) to preserve real-time delivery.
- Automatically ignores responses that already have a
- Weightless: Zero external dependencies, leveraging native runtime primitives.