1.1.0 • Published 6 years ago

@rill/unhandled v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Utility to create Rill middleware that only runs on unhandled requests.

Installation

npm install @rill/unhandled

Example

const app = require('rill')()
const redirect = require('@rill/redirect')
const unhandled = require('@rill/unhandled')

// Redirect to 404 when page is unhandled.
app.get(unhandled(redirect('/404')))

// Example routes.
app.get('/home', render(homePage))
app.get('/404', render(notFoungPage))

Details

The middleware provided to unhandled will only be invoked when the following conditions are met.

  1. res.body is undefined.
  2. res.status is 404.
  3. res.get('Location') is undefined.
  4. res.get('Content-Type') is undefined.

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!