This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std/http/server.ts"; | |
import * as RateLimiterFlexible from "https://dev.jspm.io/rate-limiter-flexible"; | |
const rateLimiter = new RateLimiterFlexible.default.RateLimiterMemory({ | |
points: 2, | |
duration: 5, | |
}); | |
const s = serve({ port: 8000 }); | |
console.log("http://localhost:8000/"); | |
for await (const req of s) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {RateLimiterRedis, BurstyRateLimiter} = require('rate-limiter-flexible'); | |
const cluster = require('cluster'); | |
const http = require('http'); | |
const Ioredis = require('ioredis'); | |
const redisClient = new Ioredis({}); | |
const TokenBucket = require('hyacinth'); | |
const numberOfUsers = 100; | |
if (cluster.isMaster) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response } from 'express'; | |
import { Body, Controller, Post, Req, Res } from '@nestjs/common'; | |
import { UserService } from './user.service'; | |
import * as Redis from 'ioredis'; | |
import { RateLimiterRedis } from 'rate-limiter-flexible'; | |
const redisClient = new Redis({enableOfflineQueue: false}); | |
const maxWrongAttemptsByIPperDay = 100; | |
const maxConsecutiveFailsByUsernameAndIP = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const express = require('express'); | |
const Redis = require('ioredis'); | |
const { RateLimiterRedis } = require('rate-limiter-flexible'); | |
const redisClient = new Redis({ enableOfflineQueue: false }); | |
const maxWrongAttemptsByIPperDay = 100; | |
const maxConsecutiveFailsByUsernameAndIP = 10; | |
const maxWrongAttemptsByUsernamePerDay = 50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const express = require('express'); | |
const Redis = require('ioredis'); | |
const { RateLimiterRedis } = require('rate-limiter-flexible'); | |
const redisClient = new Redis({ enableOfflineQueue: false }); | |
const maxWrongAttemptsByIPperDay = 100; | |
const maxConsecutiveFailsByUsernameAndIP = 10; | |
const limiterSlowBruteByIP = new RateLimiterRedis({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const express = require('express'); | |
const Redis = require('ioredis'); | |
const { RateLimiterRedis } = require('rate-limiter-flexible'); | |
const redisClient = new Redis({ enableOfflineQueue: false }); | |
const maxWrongAttemptsByIPperMinute = 5; | |
const maxWrongAttemptsByIPperDay = 100; | |
const limiterFastBruteByIP = new RateLimiterRedis({ |