npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botblocker.pro

v1.0.0

Published

BotBlocker.Pro is an essential package for protecting your website from unwanted bots that can harm performance and security. Our powerful real-time web traffic filtering and analytics service helps you track and understand your visitors while effectively

Downloads

81

Readme

BotBlocker.Pro - Bot Detection, Visitor Filtering & IP Address Intelligence

BotBlocker.Pro is a powerful Node.js and TypeScript module designed to enhance web security, filter traffic, and provide valuable analytics. It protects your application by identifying and blocking potentially harmful traffic based on IP addresses, user agents, and visitor behaviors. With BotBlocker.Pro, you can effectively defend your website against bots, competitors, and unwanted visitors while also gaining valuable insights into your audience.

To get started with BotBlocker.Pro, you'll need an API key and a subscription to our BotBlocker.Pro service. For further information, please check our comprehensive documentation.

Installation

Install BotBlocker.Pro using npm:

npm install botblocker.pro

Usage

Method 1: Using Express Middleware

import express from 'express';
import { BotBlocker } from 'botblocker.pro';

// Create an Express application
const app = express();
const port = 3000;

// Replace with your API key
const apiKey = 'YOUR-API-KEY';
const botBlocker = new BotBlocker(apiKey);

// Route handler for the root URL
app.get('/', async (req, res) => {
    try {
        const result = await botBlocker.checkReq(req);

        // User info (location and other data)
        let info = result.data.info;
        let location = info.ipinfo;

        if (result.data.block_access) {
            // Action to take if the user should be blocked
            res.status(403).json({message: 'Access denied'});
        } else {
            // Action to take if the user is allowed
            res.json({message: 'Welcome', location: location});
        }
    } catch (error) {
        // Handle any errors that occur
        console.error('Error:', error.message);
        res.status(500).json({error: 'Internal Server Error', details: error.message});
    }
});

// Start the Express server and listen on the specified port
app.listen(port, () => {
    console.log(`Server running at http://localhost:${port}`);
});

Method 2: Manually Providing IP, User-Agent, URL (Page)

const { BotBlocker } = require('botblocker.pro');

// Replace with your API key
const apiKey = 'YOUR-API-KEY';
const botBlocker = new BotBlocker(apiKey);

// Example visitor data
const userIP = '1.1.1.1'; // Replace with the visitor's IP
const userAgent = 'Mozilla/5.0 ...'; // Replace with the visitor's User-Agent
const url = 'blog/slug?query='; // Replace with URL or the page that the visitor accessed

// Manually evaluate visitor
botBlocker.check(userIP, userAgent, url)
    .then(result => {
        // User info (location and other data)
        let info = result.data.info;
        let location = info.ipinfo;

        console.log('Check result:', result);
        if (result.data.block_access) {
            // Action to take if the user should be blocked
            console.log('Block the user');
        } else {
            // Action to take if the user is allowed
            console.log('Allow the user');
        }
    })
    .catch(error => {
        // Handle any errors that occur
        console.error('Error:', error);
    });

Replace YOUR-API-KEY with your actual BotBlocker.Pro API credentials in both methods.

Contributing

We appreciate your contributions! If you're planning to make significant changes, please start by opening an issue to discuss your proposed modifications. Additionally, ensure that you update any relevant tests as needed.

License

This project is licensed under the MIT license.