# micro-compress

> Compression for HTTP microservices built with Micro

Latest version **1.0.0** (published 2016-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install micro-compress
pnpm add micro-compress
yarn add micro-compress
bun add micro-compress
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-09-22 |
| First published | 2016-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Joakim Carlstein |
| Maintainers | joakimbeng |
| Keywords | micro, compression, gzip, microservice, http, compress |

## Links

- npm: https://www.npmjs.com/package/micro-compress
- Repository: https://github.com/joakimbeng/micro-compress
- Homepage: https://github.com/joakimbeng/micro-compress#readme
- Issues: https://github.com/joakimbeng/micro-compress/issues
- npm.io page: https://npm.io/package/micro-compress

## Dependencies (1)

- [compression](https://npm.io/package/compression.md) ^1.6.2

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-09-22

## README

# micro-compress

[![Build status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![XO code style][codestyle-image]][codestyle-url]

> Compression for HTTP microservices built with [Micro](https://github.com/zeit/micro)

## Installation

Install `micro-compress` using [npm](https://www.npmjs.com/):

```bash
npm install --save micro-compress
```

## Usage

### Module usage

Just wrap your [Micro](https://github.com/zeit/micro) HTTP microservice with this module:

```javascript
const {send, json} = require('micro');
const compress = require('micro-compress');

module.exports = compress(async (req, res) => {
	const body = await json(req);
	send(res, 200, body);
});
```

Options for the [`compression`](https://github.com/expressjs/compression) module are passed as the first parameter:

```javascript
const {Z_BEST_COMPRESSION} = require('zlib');
const {send, json} = require('micro');
const compress = require('micro-compress');

module.exports = compress({level: Z_BEST_COMPRESSION}, async (req, res) => {
 const body = await json(req);
 send(res, 200, body);
});
```

## API

### `compress(opts, fn)`

| Name | Type | Description |
|------|------|-------------|
| opts | `object` | Optional. Options passed to [`compression`](https://github.com/expressjs/compression) |
| fn | `function` | The request handler to wrap |

For available options see [`compression`'s options](https://github.com/expressjs/compression#options).

## License

MIT © [Joakim Carlstein](http://joakim.beng.se)

[npm-url]: https://npmjs.org/package/micro-compress
[npm-image]: https://badge.fury.io/js/micro-compress.svg
[travis-url]: https://travis-ci.org/joakimbeng/micro-compress
[travis-image]: https://travis-ci.org/joakimbeng/micro-compress.svg?branch=master
[codestyle-url]: https://github.com/sindresorhus/xo
[codestyle-image]: https://img.shields.io/badge/code%20style-XO-5ed9c7.svg?style=flat

---
_Source: https://npm.io/package/micro-compress · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
