@routes/isbot

2.0.2Β β€’Β PublicΒ β€’Β Published

@routes/isbot

πŸ•· Express middleware to detect crawler requests: request.isbot

The middleware adds a getter to the request: isbot.

  • βœ… Lazy processing: performs the check only if it's actually used
  • βœ… Memoisation: Operation result is cached
  • βœ… Quick and Simple: Only check if it's a known crawler, does not parse the user agent string to a complex object
  • βœ… Customisable bot list
const isbot = require('@routes/isbot');

app.use(isbot);

app.get('/api', (request, response) => {
	if (request.isbot) {
		// do things
	}
	...

	response.sendStatus(200);
});

Customisation

All customisation options from isbot package are also available here

isbot.exclude(['bot']);
isbot.extend(['(?<! cu)bot']);

Package Sidebar

Install

npm i @routes/isbot

Weekly Downloads

56

Version

2.0.2

License

MIT

Unpacked Size

1.99 kB

Total Files

3

Last publish

Collaborators

  • omrilotan