halt-rate 0.1.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.
@@ -0,0 +1,21 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { R as RateLimiter } from '../limiter-qGH_X_KH.mjs';
3
+
4
+ /**
5
+ * Express middleware adapter for Halt rate limiting.
6
+ */
7
+
8
+ interface ExpressHaltOptions {
9
+ limiter: RateLimiter;
10
+ onBlocked?: (req: Request, res: Response) => void;
11
+ }
12
+ /**
13
+ * Create Express middleware for rate limiting.
14
+ */
15
+ declare function haltMiddleware(options: ExpressHaltOptions): (req: Request, res: Response, next: NextFunction) => void;
16
+ /**
17
+ * Create a route-specific rate limiter middleware.
18
+ */
19
+ declare function createLimiter(limiter: RateLimiter): (req: Request, res: Response, next: NextFunction) => void;
20
+
21
+ export { type ExpressHaltOptions, createLimiter, haltMiddleware };
@@ -0,0 +1,21 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { R as RateLimiter } from '../limiter-qGH_X_KH.js';
3
+
4
+ /**
5
+ * Express middleware adapter for Halt rate limiting.
6
+ */
7
+
8
+ interface ExpressHaltOptions {
9
+ limiter: RateLimiter;
10
+ onBlocked?: (req: Request, res: Response) => void;
11
+ }
12
+ /**
13
+ * Create Express middleware for rate limiting.
14
+ */
15
+ declare function haltMiddleware(options: ExpressHaltOptions): (req: Request, res: Response, next: NextFunction) => void;
16
+ /**
17
+ * Create a route-specific rate limiter middleware.
18
+ */
19
+ declare function createLimiter(limiter: RateLimiter): (req: Request, res: Response, next: NextFunction) => void;
20
+
21
+ export { type ExpressHaltOptions, createLimiter, haltMiddleware };
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ // src/core/decision.ts
4
+ function toHeaders(decision) {
5
+ const headers = {
6
+ "RateLimit-Limit": String(decision.limit),
7
+ "RateLimit-Remaining": String(Math.max(0, decision.remaining)),
8
+ "RateLimit-Reset": String(decision.resetAt)
9
+ };
10
+ if (!decision.allowed && decision.retryAfter !== void 0) {
11
+ headers["Retry-After"] = String(decision.retryAfter);
12
+ }
13
+ return headers;
14
+ }
15
+
16
+ // src/adapters/express.ts
17
+ function haltMiddleware(options) {
18
+ return (req, res, next) => {
19
+ Promise.resolve(options.limiter.check(req)).then((decision) => {
20
+ if (decision.allowed) {
21
+ const headers = toHeaders(decision);
22
+ for (const [key, value] of Object.entries(headers)) {
23
+ res.setHeader(key, value);
24
+ }
25
+ next();
26
+ } else {
27
+ if (options.onBlocked) {
28
+ options.onBlocked(req, res);
29
+ } else {
30
+ const headers = toHeaders(decision);
31
+ for (const [key, value] of Object.entries(headers)) {
32
+ res.setHeader(key, value);
33
+ }
34
+ res.status(429).json({
35
+ error: "rate_limit_exceeded",
36
+ message: "Too many requests. Please try again later.",
37
+ retryAfter: decision.retryAfter
38
+ });
39
+ }
40
+ }
41
+ }).catch(next);
42
+ };
43
+ }
44
+ function createLimiter(limiter) {
45
+ return (req, res, next) => {
46
+ Promise.resolve(limiter.check(req)).then((decision) => {
47
+ if (decision.allowed) {
48
+ const headers = toHeaders(decision);
49
+ for (const [key, value] of Object.entries(headers)) {
50
+ res.setHeader(key, value);
51
+ }
52
+ next();
53
+ } else {
54
+ const headers = toHeaders(decision);
55
+ for (const [key, value] of Object.entries(headers)) {
56
+ res.setHeader(key, value);
57
+ }
58
+ res.status(429).json({
59
+ error: "rate_limit_exceeded",
60
+ message: "Too many requests. Please try again later.",
61
+ retryAfter: decision.retryAfter
62
+ });
63
+ }
64
+ }).catch(next);
65
+ };
66
+ }
67
+
68
+ exports.createLimiter = createLimiter;
69
+ exports.haltMiddleware = haltMiddleware;
70
+ //# sourceMappingURL=express.js.map
71
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/decision.ts","../../src/adapters/express.ts"],"names":[],"mappings":";;;AAoBO,SAAS,UAAU,QAAA,EAA4C;AAClE,EAAA,MAAM,OAAA,GAAkC;AAAA,IACpC,i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AAA,CAAM,IAAI,CAAA;AAAA,EACjB,CAAA;AACJ","file":"express.js","sourcesContent":["/**\n * Decision model for rate limiting results.\n */\n\nexport interface Decision {\n /** Whether the request is allowed */\n allowed: boolean;\n /** Maximum number of requests allowed in the window */\n limit: number;\n /** Number of requests remaining in the current window */\n remaining: number;\n /** Unix timestamp when the limit resets */\n resetAt: number;\n /** Seconds to wait before retrying (only set when blocked) */\n retryAfter?: number;\n}\n\n/**\n * Convert decision to standard rate limit headers.\n */\nexport function toHeaders(decision: Decision): Record<string, string> {\n const headers: Record<string, string> = {\n 'RateLimit-Limit': String(decision.limit),\n 'RateLimit-Remaining': String(Math.max(0, decision.remaining)),\n 'RateLimit-Reset': String(decision.resetAt),\n };\n\n if (!decision.allowed && decision.retryAfter !== undefined) {\n headers['Retry-After'] = String(decision.retryAfter);\n }\n\n return headers;\n}\n","/**\n * Express middleware adapter for Halt rate limiting.\n */\n\nimport { Request, Response, NextFunction } from 'express';\nimport { RateLimiter } from '../core/limiter';\nimport { toHeaders } from '../core/decision';\n\nexport interface ExpressHaltOptions {\n limiter: RateLimiter;\n onBlocked?: (req: Request, res: Response) => void;\n}\n\n/**\n * Create Express middleware for rate limiting.\n */\nexport function haltMiddleware(options: ExpressHaltOptions) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(options.limiter.check(req)).then((decision) => {\n if (decision.allowed) {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n next();\n } else {\n if (options.onBlocked) {\n options.onBlocked(req, res);\n } else {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n\n res.status(429).json({\n error: 'rate_limit_exceeded',\n message: 'Too many requests. Please try again later.',\n retryAfter: decision.retryAfter,\n });\n }\n }\n }).catch(next);\n };\n}\n\n/**\n * Create a route-specific rate limiter middleware.\n */\nexport function createLimiter(limiter: RateLimiter) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(limiter.check(req)).then((decision) => {\n if (decision.allowed) {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n next();\n } else {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n\n res.status(429).json({\n error: 'rate_limit_exceeded',\n message: 'Too many requests. Please try again later.',\n retryAfter: decision.retryAfter,\n });\n }\n }).catch(next);\n };\n}\n"]}
@@ -0,0 +1,68 @@
1
+ // src/core/decision.ts
2
+ function toHeaders(decision) {
3
+ const headers = {
4
+ "RateLimit-Limit": String(decision.limit),
5
+ "RateLimit-Remaining": String(Math.max(0, decision.remaining)),
6
+ "RateLimit-Reset": String(decision.resetAt)
7
+ };
8
+ if (!decision.allowed && decision.retryAfter !== void 0) {
9
+ headers["Retry-After"] = String(decision.retryAfter);
10
+ }
11
+ return headers;
12
+ }
13
+
14
+ // src/adapters/express.ts
15
+ function haltMiddleware(options) {
16
+ return (req, res, next) => {
17
+ Promise.resolve(options.limiter.check(req)).then((decision) => {
18
+ if (decision.allowed) {
19
+ const headers = toHeaders(decision);
20
+ for (const [key, value] of Object.entries(headers)) {
21
+ res.setHeader(key, value);
22
+ }
23
+ next();
24
+ } else {
25
+ if (options.onBlocked) {
26
+ options.onBlocked(req, res);
27
+ } else {
28
+ const headers = toHeaders(decision);
29
+ for (const [key, value] of Object.entries(headers)) {
30
+ res.setHeader(key, value);
31
+ }
32
+ res.status(429).json({
33
+ error: "rate_limit_exceeded",
34
+ message: "Too many requests. Please try again later.",
35
+ retryAfter: decision.retryAfter
36
+ });
37
+ }
38
+ }
39
+ }).catch(next);
40
+ };
41
+ }
42
+ function createLimiter(limiter) {
43
+ return (req, res, next) => {
44
+ Promise.resolve(limiter.check(req)).then((decision) => {
45
+ if (decision.allowed) {
46
+ const headers = toHeaders(decision);
47
+ for (const [key, value] of Object.entries(headers)) {
48
+ res.setHeader(key, value);
49
+ }
50
+ next();
51
+ } else {
52
+ const headers = toHeaders(decision);
53
+ for (const [key, value] of Object.entries(headers)) {
54
+ res.setHeader(key, value);
55
+ }
56
+ res.status(429).json({
57
+ error: "rate_limit_exceeded",
58
+ message: "Too many requests. Please try again later.",
59
+ retryAfter: decision.retryAfter
60
+ });
61
+ }
62
+ }).catch(next);
63
+ };
64
+ }
65
+
66
+ export { createLimiter, haltMiddleware };
67
+ //# sourceMappingURL=express.mjs.map
68
+ //# sourceMappingURL=express.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/decision.ts","../../src/adapters/express.ts"],"names":[],"mappings":";AAoBO,SAAS,UAAU,QAAA,EAA4C;AAClE,EAAA,MAAM,OAAA,GAAkC;AAAA,IACpC,iBAAA,EAAmB,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA;AAAA,IACxC,uBAAuB,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG,QAAA,CAAS,SAAS,CAAC,CAAA;AAAA,IAC7D,iBAAA,EAAmB,MAAA,CAAO,QAAA,CAAS,OAAO;AAAA,GAC9C;AAEA,EAAA,IAAI,CAAC,QAAA,CAAS,OAAA,IAAW,QAAA,CAAS,eAAe,MAAA,EAAW;AACxD,IAAA,OAAA,CAAQ,aAAa,CAAA,GAAI,MAAA,CAAO,QAAA,CAAS,UAAU,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,OAAA;AACX;;;AChBO,SAAS,eAAe,OAAA,EAA6B;AACxD,EAAA,OAAO,CAAC,GAAA,EAAc,GAAA,EAAe,IAAA,KAAuB;AACxD,IAAA,OAAA,CAAQ,OAAA,CAAQ,QAAQ,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAC,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,KAAa;AAC3D,MAAA,IAAI,SAAS,OAAA,EAAS;AAClB,QAAA,MAAM,OAAA,GAAU,UAAU,QAAQ,CAAA;AAClC,QAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,O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MACT,CAAA,MAAO;AACH,QAAA,MAAM,OAAA,GAAU,UAAU,QAAQ,CAAA;AAClC,QAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAChD,UAAA,GAAA,CAAI,SAAA,CAAU,KAAK,KAAK,CAAA;AAAA,QAC5B;AAEA,QAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK;AAAA,UACjB,KAAA,EAAO,qBAAA;AAAA,UACP,OAAA,EAAS,4CAAA;AAAA,UACT,YAAY,QAAA,CAAS;AAAA,SACxB,CAAA;AAAA,MACL;AAAA,IACJ,CAAC,CAAA,CAAE,KAAA,CAAM,IAAI,CAAA;AAAA,EACjB,CAAA;AACJ","file":"express.mjs","sourcesContent":["/**\n * Decision model for rate limiting results.\n */\n\nexport interface Decision {\n /** Whether the request is allowed */\n allowed: boolean;\n /** Maximum number of requests allowed in the window */\n limit: number;\n /** Number of requests remaining in the current window */\n remaining: number;\n /** Unix timestamp when the limit resets */\n resetAt: number;\n /** Seconds to wait before retrying (only set when blocked) */\n retryAfter?: number;\n}\n\n/**\n * Convert decision to standard rate limit headers.\n */\nexport function toHeaders(decision: Decision): Record<string, string> {\n const headers: Record<string, string> = {\n 'RateLimit-Limit': String(decision.limit),\n 'RateLimit-Remaining': String(Math.max(0, decision.remaining)),\n 'RateLimit-Reset': String(decision.resetAt),\n };\n\n if (!decision.allowed && decision.retryAfter !== undefined) {\n headers['Retry-After'] = String(decision.retryAfter);\n }\n\n return headers;\n}\n","/**\n * Express middleware adapter for Halt rate limiting.\n */\n\nimport { Request, Response, NextFunction } from 'express';\nimport { RateLimiter } from '../core/limiter';\nimport { toHeaders } from '../core/decision';\n\nexport interface ExpressHaltOptions {\n limiter: RateLimiter;\n onBlocked?: (req: Request, res: Response) => void;\n}\n\n/**\n * Create Express middleware for rate limiting.\n */\nexport function haltMiddleware(options: ExpressHaltOptions) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(options.limiter.check(req)).then((decision) => {\n if (decision.allowed) {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n next();\n } else {\n if (options.onBlocked) {\n options.onBlocked(req, res);\n } else {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n\n res.status(429).json({\n error: 'rate_limit_exceeded',\n message: 'Too many requests. Please try again later.',\n retryAfter: decision.retryAfter,\n });\n }\n }\n }).catch(next);\n };\n}\n\n/**\n * Create a route-specific rate limiter middleware.\n */\nexport function createLimiter(limiter: RateLimiter) {\n return (req: Request, res: Response, next: NextFunction) => {\n Promise.resolve(limiter.check(req)).then((decision) => {\n if (decision.allowed) {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n next();\n } else {\n const headers = toHeaders(decision);\n for (const [key, value] of Object.entries(headers)) {\n res.setHeader(key, value);\n }\n\n res.status(429).json({\n error: 'rate_limit_exceeded',\n message: 'Too many requests. Please try again later.',\n retryAfter: decision.retryAfter,\n });\n }\n }).catch(next);\n };\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { a as RateLimiterOptions, P as Policy } from '../limiter-qGH_X_KH.mjs';
3
+
4
+ /**
5
+ * Next.js adapter for Halt rate limiting.
6
+ */
7
+
8
+ /**
9
+ * Create Next.js middleware for rate limiting.
10
+ */
11
+ declare function haltMiddleware(options: RateLimiterOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
12
+ /**
13
+ * Wrapper for Next.js route handlers to add rate limiting.
14
+ */
15
+ declare function withHalt<T extends (...args: any[]) => Promise<Response>>(handler: T, options: RateLimiterOptions): T;
16
+ /**
17
+ * Simple wrapper that accepts just a policy for convenience.
18
+ */
19
+ declare function withPolicy<T extends (...args: any[]) => Promise<Response>>(handler: T, policy: Policy, store: RateLimiterOptions['store']): T;
20
+
21
+ export { haltMiddleware, withHalt, withPolicy };
@@ -0,0 +1,21 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { a as RateLimiterOptions, P as Policy } from '../limiter-qGH_X_KH.js';
3
+
4
+ /**
5
+ * Next.js adapter for Halt rate limiting.
6
+ */
7
+
8
+ /**
9
+ * Create Next.js middleware for rate limiting.
10
+ */
11
+ declare function haltMiddleware(options: RateLimiterOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
12
+ /**
13
+ * Wrapper for Next.js route handlers to add rate limiting.
14
+ */
15
+ declare function withHalt<T extends (...args: any[]) => Promise<Response>>(handler: T, options: RateLimiterOptions): T;
16
+ /**
17
+ * Simple wrapper that accepts just a policy for convenience.
18
+ */
19
+ declare function withPolicy<T extends (...args: any[]) => Promise<Response>>(handler: T, policy: Policy, store: RateLimiterOptions['store']): T;
20
+
21
+ export { haltMiddleware, withHalt, withPolicy };