MCPcopy Index your code
hub / github.com/simstudioai/sim / sweepRateLimit

Function sweepRateLimit

apps/docs/app/api/chat/route.ts:88–93  ·  view source on GitHub ↗

Drop expired buckets so the Map doesn't grow unbounded on a long-lived instance.

(now: number)

Source from the content-addressed store, hash-verified

86
87/** Drop expired buckets so the Map doesn't grow unbounded on a long-lived instance. */
88function sweepRateLimit(now: number): void {
89 if (rateLimitHits.size < 10_000) return
90 for (const [ip, entry] of rateLimitHits) {
91 if (now >= entry.resetAt) rateLimitHits.delete(ip)
92 }
93}
94
95/** A structurally valid UI message: has a role and a parts array. */
96function isValidMessage(message: unknown): message is UIMessage {

Callers 1

POSTFunction · 0.85

Calls 1

deleteMethod · 0.65

Tested by

no test coverage detected