MCPcopy
hub / github.com/cursor/community-plugins / check

Function check

apps/cursor/src/lib/rate-limit.ts:44–69  ·  view source on GitHub ↗
({
  rateLimitId,
  rateLimitKey,
}: {
  rateLimitId: string;
  rateLimitKey?: string;
})

Source from the content-addressed store, hash-verified

42}
43
44async function check({
45 rateLimitId,
46 rateLimitKey,
47}: {
48 rateLimitId: string;
49 rateLimitKey?: string;
50}): Promise<LimitResult> {
51 const requestHeaders = await getRequestHeaders();
52 const { rateLimited, error } = await checkRateLimit(rateLimitId, {
53 headers: requestHeaders,
54 rateLimitKey,
55 firewallHostForDevelopment,
56 });
57
58 // We deliberately fail open on misconfiguration: a missing dashboard rule
59 // shouldn't lock out every user (worse than no rate limit). But silent
60 // fail-open is dangerous, so surface it loudly so it's caught in
61 // production logs / alerting instead of going unnoticed.
62 if (error === "not-found") {
63 console.error(
64 `[rate-limit] Vercel Firewall rule '${rateLimitId}' is not configured. Rate limiting is DISABLED for this rule until the rule is created in the Firewall dashboard.`,
65 );
66 }
67
68 return { success: !rateLimited };
69}
70
71export async function installPerPluginLimit(
72 pluginId: string,

Callers 3

installPerPluginLimitFunction · 0.85
installGlobalLimitFunction · 0.85
pluginScanLimitFunction · 0.85

Calls 1

getRequestHeadersFunction · 0.85

Tested by

no test coverage detected