Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deviate

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deviate

Redirecting middlware for express or node.js

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
# deviate

Redirecting middlware for express or node.js

  • supports 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 Dependency Status

Usage

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

Keywords

FAQs

Package last updated on 25 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc