mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add definition for "express-brute-memcached".
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/// <reference path="../express-brute/express-brute.d.ts"/>
|
||||
/// <reference path="../mongodb/mongodb.d.ts"/>
|
||||
/// <reference path="express-brute-memcached.d.ts"/>
|
||||
|
||||
import express = require("express");
|
||||
import ExpressBrute = require("express-brute");
|
||||
import MemcachedStore = require("express-brute-memcached");
|
||||
|
||||
var app = express();
|
||||
var store = new MemcachedStore("127.0.0.1");
|
||||
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!');
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,114 @@
|
||||
// Type definitions for express-brute-memcached
|
||||
// Project: https://github.com/AdamPflug/express-brute-memcached
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module "express-brute-memcached" {
|
||||
/**
|
||||
* @summary Memcached options.
|
||||
* @interface
|
||||
*/
|
||||
interface MemcachedStoreOptions {
|
||||
prefix: string;
|
||||
|
||||
/**
|
||||
* @summary Maximum key size allowed.
|
||||
* @type {number}
|
||||
*/
|
||||
maxKeySize: number;
|
||||
|
||||
/**
|
||||
* @summary Maximum expiration time of keys (in seconds).
|
||||
* @type {number}
|
||||
*/
|
||||
maxExpiration: number;
|
||||
|
||||
/**
|
||||
* @summary Maximum size of a value.
|
||||
* @type {number}
|
||||
*/
|
||||
maxValue: number;
|
||||
|
||||
/**
|
||||
* @summary Maximum size of the connection pool.
|
||||
* @type {number}
|
||||
*/
|
||||
poolSize: number;
|
||||
|
||||
/**
|
||||
* @summary Hashing algorithm used to generate the hashRing values
|
||||
* @type {string}
|
||||
*/
|
||||
algorithm: string;
|
||||
|
||||
/**
|
||||
* @summary Time between reconnection attempts (in milliseconds).
|
||||
* @type {number}
|
||||
*/
|
||||
reconnect: number;
|
||||
|
||||
/**
|
||||
* @summary Time after which Memcached sends a connection timeout (in milliseconds).
|
||||
* @type {number}
|
||||
*/
|
||||
timeout: number;
|
||||
|
||||
/**
|
||||
* @summary Number of socket allocation retries per request.
|
||||
* @type {number}
|
||||
*/
|
||||
retries: number;
|
||||
|
||||
/**
|
||||
* @summary Number of failed-attempts to a server before it is regarded as 'dead'.
|
||||
* @type {number}
|
||||
*/
|
||||
failures: number;
|
||||
|
||||
/**
|
||||
* @summary Time between a server failure and an attempt to set it up back in service.
|
||||
* @type {number}
|
||||
*/
|
||||
retry: number;
|
||||
|
||||
/**
|
||||
* @summary If true, authorizes the automatic removal of dead servers from the pool.
|
||||
* @type {boolean}
|
||||
*/
|
||||
remove: boolean;
|
||||
|
||||
/**
|
||||
* @summary An array of server_locations to replace servers that fail and that are removed from the consistent hashing scheme.
|
||||
* @type {Array}
|
||||
*/
|
||||
failOverServers: Array<any>;
|
||||
|
||||
/**
|
||||
* @summary True, whether to use md5 as hashing scheme when keys exceed maxKeySize .
|
||||
* @type
|
||||
*/
|
||||
keyCompression: boolean;
|
||||
|
||||
/**
|
||||
* @summary Idle timeout for the connections.
|
||||
* @type {number}
|
||||
*/
|
||||
idle: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary A memcached store adapter.
|
||||
* @class
|
||||
*/
|
||||
export = class MemcachedStore {
|
||||
/**
|
||||
* @summary Constructor.
|
||||
* @constructor
|
||||
* @param {string|Array} hosts The collection.
|
||||
* @param {Object} options The otpions.
|
||||
*/
|
||||
constructor(hosts: string|Array<string>, options?: MemcachedStoreOptions);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user