@aleph/express-json-redirects

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @aleph/express-json-redirects

Weekly Downloads

3

Version

0.0.1

License

MPL-2.0

Unpacked Size

25.9 kB

Total Files

8

Last publish

Collaborators

  • tusinga
  • alephsf
  • oppodeldoc