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

httpfilter

v0.1.1

Published

To filter http requests before trying to process it at all

Downloads

3

Readme

filter

A filter middleware to filter http requests, and block some unwanted requests type.

Installation

$ npm install httpfilter

API

There are two major ways to use the filter API.

Configure Model


var filter = require('httpfilter');

filter(serverOptions)

filter(serverOptions)

Returns an Object that would be ready to filter on a call to .start(). It would recieved the request, response and next args and run filter. E.g filter.start(request, response, next); IT integrates into expressjs to call next for the next middleware

On-the-fly Model


var filter = require('filter');

filter(request, response, serverOptions, next)

Does not return any object, it passes the serverOptions directly to the middleware call and off they go into processing

serverOptions

This is a plain object containing strictly the following

versions

This contains an array of strings containing http versions allowed on this server e.g

	versions: ["1.0", "1.1"] // this server does not support http2

allow

This contains an array of strings containing http methods allowed on this server e.g

	allow: ["GET", "POST"] // this server does allows only GET and POST methods

proxy

This identifies a proxying requests and allows or denies them depending on the value of proxy property. The value options are: allow, less-strict, deny

	proxy: "deny" // this server does not support http2
allow

This does not put any restriction. But allows any form of proxying take place, e.g proxying to another machine, or host number.

less-strict

This restricts proxying to an external machine, but not proxying to the same machine, but on different ports.

deny

This restricts every form of proxying both to an external machince, and even internal proxying

hostname

This is a string contains the virtual hostname. To parse against the hostname, when running a number on virtual hosts on the same machine.

	hostname: "localhost" // this server supports requests from localhost only.

alias

This is a string containing hostname aliases seperated by " ". Used for detailed checking of the hostname field

	alias: "home filter" // alias used to add more options for hostname test above

ip

This is used to check for proxying requests. ip is a string in numeric form.

	ip: "127.0.0.1" // this server restricts requests not sent to localhost, when proxy is set to deny

Examples

Using expressjs

Configure Model


var filter = require('filter');
var express = require('express');

var app = express();

filter = filter(serverOptions)

app.use(filter);

On-the-fly Model

var filter = require('filter');
var express = require('express');

var app = express();
var serverOptions = {};

app.use(function(req, res, next) {
	filter(req, res, serverOptions, next);
})

Tests

There are no tests ... coming soon.

License

MIT