express-hawk
v1.1.1
Published
Identifies bots/crawlers
Downloads
5
Maintainers
Readme
express-hawk
Express middleware written in Typescript for identifying requests of bots/crawlers.
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