express-hawk
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

express-hawk

Express middleware written in Typescript for identifying requests of bots/crawlers.

Build Status Coverage Status Greenkeeper badge

This library was inspired by es6-crawler-detect. The blacklist is taken from Crawler-Detect.

Installation

yarn add express-hawk

Note: Please keep in mind that this is a very basic check because the user-agent-header is tampered easily.

Usage

Use express-hawk as any other express-middleware.

import express, {Request, Response} from "express";
import {hawk} from "express-hawk";

const app = express();
app.use(hawk());

app.get("/", (req: Request, res: Response) => {
    // req.isBot is now either true or false
});

The middleware uses the blacklist user-agent.blacklist. On each request it checks if the user-agent-header matches with an entry of this list. It sets req.isBot accordingly.

Tests

$ yarn install
$ yarn test

Package Sidebar

Install

npm i express-hawk

Weekly Downloads

4

Version

1.1.1

License

ISC

Unpacked Size

19.6 kB

Total Files

6

Last publish

Collaborators

  • mrschneepflug