INNER CODE UNIT · TypeScript

nextCount

Ammaar-Alam/minebench · middleware.ts:174

    const nextCount = !bucket || bucket.resetAt <= now ? 1 : bucket.count + 1;

    if (nextCount > rule.maxPerWindow) {
      return {
        allowed: false,
        retryAfterSeconds: Math.ceil((resetAt - now) / 1000),
      };
    }

    previews.push({ key: rule.key, resetAt, nextCount });
  }

  // commit all buckets together so partial limits cannot leak counts
  for (const preview of previews) {
    buckets.set(preview.key, { resetAt: preview.resetAt, count: preview.nextCount });
  }

  return {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…