@cfware/middleware-redirects
v0.1.1
Published
Middleware for HTTP redirects
Downloads
12
Readme
@cfware/middleware-redirects
This is a basic middleware for handling static redirects. I use it for internal
testing within gulp serve
. Chances are good it does not provide for your needs.
Install @cfware/middleware-redirects
npm i --save-dev @cfware/middleware-redirects
Usage
'use strict';
const connect = require('connect');
const redirects = require('@cfware/middleware-redirects');
// create app
const app = connect();
// Setup middleware to perform redirects
app.use(redirects({
'/': '/my-app/',
'/downloads': '/pub/my-app/',
'/downloads/': '/pub/my-app/',
}));
// Start the server on a random port at localhost.
const server = app.listen(0, 'localhost', () => {
const addr = server.address();
console.log(`Example app listening at http://${addr.address}:${addr.port}`);
});
Running tests
The only test currently provided is eslint.
npm install
npm test