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

express-flood

v1.0.0

Published

Package for managing API - filter requests for avoid spammers and robots

Downloads

2

Readme

Introduction

express-flood is a package for who want to build APIs. Often if we do many requests to a website we get the error 429, and this is a protection for avoid spammers, robots, and other bad stuff.

How does it works?

You can specify as many protected URLs as you want, it is very flexible and allow you to have high sicurity. It's based on IP address, and timestamps.

Documentation

How to install it

npm i express-flood

How to use it

const express = require('express');
const expressFlood = require('express-flood')([
	{ path: '/test', max: 3, timeout: 60000, deny: 'Cannot do that!' },
	{ path: '/flood', max: 5, timeout: 10000, deny: 'Cannot do that (2)!' }
]);

app.use(...expressFlood);

const app = express();
app.listen(3000, _ => console.log('Server started'));

This sample will create a protection on path '/test', where a user can make up to 3 requests in 1 minutes; if someone try to go beyond, will se the message 'Cannot do that!'. An also another protection on path '/flood'

Options

path

It is the path of url to protect, it could be also '/api/something/:test'

max

Max requests that a user can do within 'timeout' time

timeout

When the protection allow user to make a new cycle of requests (in milliseconds)

deny

Accepted types of this parameter: 'string', 'object', 'function' If someone try to go beyond protection limits, he will se the message you passed if it a string or object, or if it is a function, it will be called with 2 arguments (request and response) for manging user request.

force

By default, it is set to true.

Let's say a user is reloading the page continuously If it is set to true: - The user can only make 'max' requests, after which the system will completely block the others until it stops making them for 'timeout' milliseconds If it is set to false: - The user can make 'max' requests and after 'timeout' milliseconds the server will be able to accept others, ignoring those that are blocked (NOT RECOMMENDED)