@harshror77/rate-limiter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@harshror77/rate-limiter",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "src/index.js"
6
+ }
@@ -0,0 +1,11 @@
1
+ export const PLANS = {
2
+ FREE: 'free',
3
+ PRO: 'pro',
4
+ ENTERPRISE: 'enterprise',
5
+ };
6
+
7
+ export const ALGORITHMS = {
8
+ TOKEN_BUCKET: 'token_bucket',
9
+ SLIDING_WINDOW: 'sliding_window',
10
+ FIXED_WINDOW: 'fixed_window',
11
+ };
package/src/types.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @typedef {Object} RateLimitRequest
3
+ * @property {string} ip
4
+ * @property {string} [userId]
5
+ * @property {string} apiKey
6
+ * @property {string} [planId]
7
+ */
8
+
9
+ /**
10
+ * @typedef {Object} RateLimitResult
11
+ * @property {boolean} allowed
12
+ * @property {number} [remaining]
13
+ * @property {number} [resetAt]
14
+ * @property {string} [deniedBy]
15
+ */
16
+
17
+ /**
18
+ * @typedef {Object} ClientConfig
19
+ * @property {string} apiKey
20
+ * @property {string} clientName
21
+ * @property {string} planId
22
+ * @property {string} algorithm
23
+ */
24
+
25
+ export {};