Socket
Socket
Sign inDemoInstall

koa-isajax

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-isajax

Middleware for koajs 2 to check if the incoming request is an Ajax request.


Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
1
Install size
1.66 kB
Created
Weekly downloads
 

Readme

Source

koa-isajax

Express req.xhr equivalent for Koa 2 applications. Middleware for Koa 2 that sets a boolean on the ctx.state on whether or not the request is and Ajax request.

This middleware is the equivalent to Express req.xhr.

Installation

$ npm install koa-isajax --save

Example

import Koa from 'koa';
import isajax from 'koa-isajax';

const app = new Koa();

app.use(isajax());
app.use(async (ctx) => {
    if (ctx.state.xhr) {
        // Ajax request.
    } else  {
        // Not ajax request.
    }
});

app.listen(3000);

Keywords

FAQs

Last updated on 18 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc