MCPcopy Create free account
hub / github.com/brightdata/brightdata-mcp / parse_rate_limit

Function parse_rate_limit

server.js:51–67  ·  view source on GitHub ↗
(rate_limit_str)

Source from the content-addressed store, hash-verified

49
50const allowed_tools = build_allowed_tools(tool_groups, custom_tools);
51function parse_rate_limit(rate_limit_str) {
52 if (!rate_limit_str)
53 return null;
54
55 const match = rate_limit_str.match(/^(\d+)\/(\d+)([mhs])$/);
56 if (!match)
57 throw new Error('Invalid RATE_LIMIT format. Use: 100/1h or 50/30m');
58
59 const [, limit, time, unit] = match;
60 const multiplier = unit==='h' ? 3600 : unit==='m' ? 60 : 1;
61
62 return {
63 limit: parseInt(limit),
64 window: parseInt(time) * multiplier * 1000,
65 display: rate_limit_str
66 };
67}
68
69const rate_limit_config = parse_rate_limit(process.env.RATE_LIMIT);
70

Callers 1

server.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected