Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/talyssonoc/express-ajax-only
Express middleware for only accept AJAX request for a given URL
https://github.com/talyssonoc/express-ajax-only
Last synced: 19 days ago
JSON representation
Express middleware for only accept AJAX request for a given URL
- Host: GitHub
- URL: https://github.com/talyssonoc/express-ajax-only
- Owner: talyssonoc
- Created: 2014-05-11T14:48:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-15T23:09:59.000Z (over 10 years ago)
- Last Synced: 2024-10-11T10:53:44.598Z (about 1 month ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ajax-only
Express middleware for only accept AJAX request for a given URL
## Example
```js
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)