From f738a6016b28a66727d4b012fe45cb521c68b66a Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 14 Aug 2019 14:46:53 -0400 Subject: [PATCH] Init rate limiter --- lib/src/rate_limiter.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/src/rate_limiter.dart diff --git a/lib/src/rate_limiter.dart b/lib/src/rate_limiter.dart new file mode 100644 index 00000000..e7c08a88 --- /dev/null +++ b/lib/src/rate_limiter.dart @@ -0,0 +1,14 @@ +import 'package:angel_framework/angel_framework.dart'; + +/// A base class that facilitates rate limiting API's or endpoints, +/// typically to prevent spam and abuse. +abstract class RateLimiter { + /// The maximum number of requests allowed within the given [window]. + final int maxRequestsPerWindow; + + /// The amount of time, during which, a user is not allowed to send + /// more than [maxRequestsPerWindow]. + final Duration window; + + RateLimiter(this.maxRequestsPerWindow, this.window); +}