4.1.0 • Published 4 months ago

@rowanmanning/response-redirect-middleware v4.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 months ago

@rowanmanning/response-redirect-middleware

A small convenience utility to generate Express middleware which redirects a request.

app.get('/', redirect('/login'));

Table of Contents

Requirements

This library requires the following to run:

Usage

Install with npm:

npm install @rowanmanning/response-redirect-middleware

Load the library into your code with a require call:

const redirect = require('@rowanmanning/response-redirect-middleware');

Use it to generate middleware to redirect a view:

const app = express();

app.get('/', redirect('/login'));

The following are equivalent:

app.get('/', redirect('/login'));
app.get('/', (request, response) => response.redirect('/login'));
app.get('/posts', redirect(301, '/blog'));
app.get('/posts', (request, response) => response.redirect(301, '/blog'));

If you need to pass dynamic information into the redirect, don't use this middleware.

Contributing

The contributing guide is available here. All contributors must follow this library's code of conduct.

License

Licensed under the MIT license. Copyright © 2020, Rowan Manning

4.1.0

4 months ago

3.0.2

10 months ago

4.0.1

8 months ago

4.0.0

8 months ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

1.1.0

2 years ago

2.0.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago