feat: @ratelimit(strategy, limit, window) route decorator#8
Merged
Conversation
Recognize @ratelimit in the AST and lower it in buildRouteBlock to a RateLimitService.guard(routeId, tag, limit, window) call prepended to the route block, BEFORE the @auth guard (so it shields auth/body from a flood and rate-limits unauthenticated brute force). strategy is a RateLimit enum member or a bare int tag; limit/window must be integer literals, else no guard (fail-safe, like @cache). Program-wide route-id counter; the runtime + 429 response live in toiljs (RateLimitService).
BlobMaster41
added a commit
that referenced
this pull request
Jun 26, 2026
…-file (audit #7/#8/#18) - checkRpcSurfaceCollisions: reject duplicate client-facing Server keys (two @services lowercasing to the same key, a free @Remote shadowing a @service / reserved REST / Stream) and FNV method-id collisions, before the surface is emitted - else the generated Server object/type silently overwrites a key, or a collided id routes to the wrong method at dispatch. Verified: a free @Remote 'stats' colliding with @service Stats now fails the build with a clear message. - cli --rpcSurfaceFiles: a missing surface file now raises File_0_not_found (mirrors the entry loop) instead of being silently skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the
@ratelimit(strategy, limit, window)route decorator. Pairs with toil-backendfeat/email-ratelimit(theenv::ratelimit_checkhost import) and toiljsfeat/client-ip(theRateLimitServiceruntime) — all three land together.src/ast.ts: recognize@ratelimit(DecoratorKind.Ratelimit).src/parser.ts: inbuildRouteBlock, lower it to aRateLimitService.guard(routeId, tag, limit, window)call prepended to the route block, before the@authguard — so it shields the auth/body path from a flood and rate-limits unauthenticated brute force.strategyis aRateLimitenum member (FixedWindow/SlidingWindow/TokenBucket) or a bare integer tag;limit/windowmust be integer literals, else no guard is emitted (fail-safe, like@cache). A program-wide counter assigns each rate-limited route a stable id; the limiter + 429 response live host-side / in toiljs.