Registry / web-framework / micro-compress

micro-compress

JSON →
library1.0.0jsnpmunverified

Middleware to add gzip/brotli compression to HTTP microservices built with the Micro framework (from ZEIT/Now). Version 1.0.0 is stable and wraps the popular compression npm package, passing all options through. It is designed specifically for Micro's async request handler pattern, not Express or other frameworks. The package is minimal (no dependencies beyond compression and micro) and follows the same promise-based flow as Micro itself. It is released under MIT license and has not seen updates since 2017, indicating maintenance status.

npm install micro-compress
INSTALL
IMPORT
SIG · MICRO-COMPRESS
M
micro-compress
web-frameworkjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const compress = require('micro-compress');
import compress from 'micro-compress';
CommonJS only; no ESM exports. Default export is the compress function.
compress (with options)
const compress = require('micro-compress'); module.exports = compress({ level: 9 }, handler);
const { compress } = require('micro-compress');
Named export 'compress' does not exist. Use default export directly.
TypeScript usage
import compress = require('micro-compress');
import compress from 'micro-compress';
For TypeScript, use import equals (require style) or // @ts-ignore. No type declarations.

Wraps a Micro request handler with compression middleware. The handler remains async, and the response is gzip-compressed if accepted.

const { send, json } = require('micro'); const compress = require('micro-compress'); const handler = async (req, res) => { const body = await json(req); send(res, 200, body); }; module.exports = compress(handler);
Debug
Known issues
gotchamicro-compress only works with the Micro framework, not Express or other HTTP servers.
fix
Use compression middleware designed for your framework (e.g., compression for Express).
affects: >=1.0.0
gotchaNo ESM support; must use CommonJS require().
fix
Use require('micro-compress') instead of import. If you need ESM, transpile or use dynamic import.
affects: >=1.0.0
gotchaOptions object is the first argument; if omitted, default compression options are used.
fix
Pass options as first argument: compress({level: 9}, handler). Do not pass handler as first argument.
affects: >=1.0.0
gotchamicro-compress does not support brotli compression natively; relies on compression package which may not include brotli in older versions.
fix
If brotli needed, ensure compression@>=1.7.0 is installed and pass { brotli: { enabled: true } }. Check compression docs.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'micro-compress'
Forgot to run npm install or installed in wrong directory.
fix
Run npm install micro-compress in the project root.
TypeError: compress is not a function
Using named import { compress } instead of default require.
fix
Use const compress = require('micro-compress');
TypeError: Cannot read property 'writeHead' of undefined
Passed handler as first argument without wrapping correctly or missing micro peer dependency.
fix
Ensure micro is installed: npm install micro. Then wrap: compress(handler) or compress(options, handler).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
compressionrequiredCore compression logic (gzip, deflate, brotli).
microrequiredPeer dependency for HTTP microservice framework.
Agent activity
9 hits · last 30 days
node
6
Resources
micro-compress — npm install micro-compress · libregistry