import { readFileSync } from 'fs';
import { join } from 'path';
import type { Redis } from 'ioredis';
import { randomUUID } from 'crypto';
export interface LimitResult {
package feed
import (
"encoding/base64"
"encoding/json"
"time"
module MyApp
class Application < Rails::Application
config.load_defaults 6.1
# Enable response compression
config.middleware.use Rack::Deflater
import { z } from 'zod';
export const createUserSchema = z
.object({
email: z.string().email(),
name: z.string().min(1).max(120),
class WebhookSignature
class VerificationError < StandardError; end
TOLERANCE = 300 # seconds
def initialize(payload:, header:, secrets:)
package api
import "strings"
type Issue struct {
Field string `json:"field"`
package ratelimit
import (
"sync"
"time"
)
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :articles, only: [:index, :show, :create, :update, :destroy]
resources :sessions, only: [:create]
end
<?php
use Illuminate\Support\Facades\Http;
// Retry with exponential backoff
$response = Http::retry(3, 100, function ($exception, $request) {
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
class SlidingWindowLimiter
Result = Struct.new(:allowed, :count, :limit, :window_ms, keyword_init: true)
SCRIPT = <<~LUA.freeze
local key = KEYS[1]
local now = tonumber(ARGV[1])
module Api
module V1
class PostsController < BaseController
before_action :authenticate_user!
def create