ajax-only

0.0.2 • Public • Published

ajax-only

Express middleware for only accept AJAX request for a given URL

Example

    var ajaxOnly = require('ajax-only');
    app.get('/api/*', ajaxOnly([options]));
    app.get('/api/', api.index);

Options

  • redirect: URL to where the user will be redirected if using a non-AJAX request (default: false)
  • status: If using redirect, redirect it with this status. Otherwise, send a response with this status (default: 302 for redirect, 404 for body)
  • body: If not using redirect, send a response with this body (default: 'Not found' or the http.STATUS_CODE for the given status)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    2
  • 0.0.1
    2

Package Sidebar

Install

npm i ajax-only

Weekly Downloads

4

Version

0.0.2

License

none

Last publish

Collaborators

  • talyssonoc