# deviate

> Redirecting middlware for express or node.js

Latest version **1.0.0** (published 2013-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install deviate
pnpm add deviate
yarn add deviate
bun add deviate
```

## 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 | 2013-04-25 |
| First published | 2013-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | ForbesLindesay |
| Maintainers | forbeslindesay |
| Keywords | express, routing, template, redirect, expression |

## Links

- npm: https://www.npmjs.com/package/deviate
- Repository: https://github.com/ForbesLindesay/deviate
- npm.io page: https://npm.io/package/deviate

## Dependencies (1)

- [ert](https://npm.io/package/ert.md) ~1.0

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2013-04-25
- 0.0.0 — 2013-04-25

## README

<img src="http://i.imgur.com/g3GNbqw.png" align="right"/>
# deviate

Redirecting middlware for express or node.js

- supports [ert](https://github.com/ForbesLindesay/ert) syntax
- supports a function that takes `req` and returns the path
- uses `res.redirect` if it's used with express
- falls back to manually writing the header elsewhere

[![Build Status](https://travis-ci.org/ForbesLindesay/deviate.png?branch=master)](https://travis-ci.org/ForbesLindesay/deviate)
[![Dependency Status](https://gemnasium.com/ForbesLindesay/deviate.png)](https://gemnasium.com/ForbesLindesay/deviate)

## Usage

```js
var deviate = require('deviate');

var express = require('express');
var app = express();

app.get('/random', deviate(function (req) { return '/post/' + Math.random(); }));

app.get('/page/:no/next', deviate('/page/[Number:no + 1]'));
app.get('/page/:no/prev', deviate('/page/[Number:no - 1]'));

app.get('/:number', deviate(301, '/post/:number'));

app.listen(3000);
```

## API

`deviate([status,] path)`

Deviate takes an optional status (which defaults to 302) and a path or function.  It then returns a middleware function which takes `req` and `res` and redirects `res` to the path.

## License

MIT

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