Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-brute-mongoose

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-brute-mongoose

Mongoose store for express-brute.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
766
decreased by-17.1%
Maintainers
2
Weekly downloads
 
Created
Source

Mongoose store adapter for express-brute.

NPM

Installation

yarn add express-brute-mongoose

Usage

var ExpressBrute = require("express-brute");
var MongooseStore = require("express-brute-mongoose");
var BruteForceSchema = require("express-brute-mongoose/dist/schema");
var mongoose = require("mongoose");

var model = mongoose.model("bruteforce", new mongoose.Schema(BruteForceSchema));
var store = new MongooseStore(model);

var bruteforce = new ExpressBrute(store);

app.post(
  "/auth",
  bruteforce.prevent, // error 403 if we hit this route too often
  function(req, res, next) {
    res.send("Success!");
  }
);

Defining your Mongoose Schema

You can either use the default schema provided at express-brute-mongoose/schema or roll your own, as long as it matches the basic structural requirements of the schema as follows:

{
  "_id": String,
  "data": {
    "count": Number,
    "lastRequest": Date,
    "firstRequest": Date
  },
  "expires": Date
}

The default schema included in the package includes a Mongo index on the _id field and another index that will automatically delete each entry 1 day after it has passed its expires time, in an effort to keep the collection clean.

Development

Build the package with yarn compile

Run tests with yarn test

Run the linter with yarn lint

Running Tests

You should have mongo running on port 27017 before running tests. If you have docker-compose and docker installed, you can get mongo up and running by using the following command:

docker-compose up

FAQs

Package last updated on 01 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc