Skip to content

MrSchneepflug/express-hawk

Repository files navigation

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.botlist. 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

About

Identifies bots/crawlers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •