0.0.1 • Published 6 years ago

@aleph/express-json-redirects v0.0.1

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
6 years ago

express-json-redirects NPM version Build Status Dependency Status Coverage percentage

Middleware that allows you to use JSON to specify redirects in Express

Installation

$ npm install --save @aleph/express-json-redirects

Usage

Your redirects must be a JSON file with an array of objects. The properties of the objects are:

  • route (Required string) - An Express route, like /someroute
  • target (Required string) - The route to redirect to, like /target/route
  • status (Optional integer) - The redirect code you want to return, default 302
  • method (Optional string) - Express method, default all
  • qsa (Optional boolean) - Whether or not to pass along query strings, default false

This package extends the express object directly, so you must do a few things to get it to work. The basic usage alongside Express:

const jsonRedirects = require('express-json-redirects');
const redirects = require('./redirects.json');

const app = express();

jsonRedirects(app);
app.expressJsonRedirects(redirects);

License

MPL-2.0 © Matt Glaser