# express-transform

> Express middleware to transform responses

Latest version **1.0.1** (published 2015-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-transform
pnpm add express-transform
yarn add express-transform
bun add express-transform
```

## 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.1 |
| Published | 2015-11-24 |
| First published | 2015-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Olivier Lalonde |
| Maintainers | olalonde |

## Links

- npm: https://www.npmjs.com/package/express-transform
- npm.io page: https://npm.io/package/express-transform

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^2.2.0

## Recent versions

- 1.0.1 (latest) — 2015-11-24
- 1.0.0 — 2015-11-23
- 0.0.1 — 2015-11-21

## README

WIP

# express-transform

[![Build Status](https://travis-ci.org/olalonde/express-transform.svg)](https://travis-ci.org/olalonde/express-transform)

## Install

```
npm install --save express-transform
```

## Usage

Adds a `req.transform` method that can be used to pipe the response
to transform streams before it is passed to the underlying socket.

See [./test/index.js](./test/index.js).

Example for compressing response:

```javascript
import express from 'express';
import onHeaders from 'on-headers';
import transform from 'express-transform';

const app = express();
app.use(transform());
app.use((req, res, next) => {
  const gzip = zlib.createGzip();
  res.transform(gzip);

  // Some express methods automatically
  // add Content-Length header which will
  // be incorrect since we are compressing.
  onHeaders(res, function gzipOnHeaders() {
    this.setHeader('Content-Encoding', 'gzip');
    this.removeHeader('Content-Length');
  });

  next();
});

app.use((req, res) => {
  res.send('Hello World!');
});
```

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