class TokenBucket {
constructor(capacity, refillRatePerSec) {
this.capacity = capacity;
this.refillRate = refillRatePerSec;
this.tokens = capacity;
this.lastRefill = Date.now();
import { cookies } from "next/headers";
import { jwtVerify } from "jose";
export interface Session {
userId: string;
role: "user" | "admin";
# Basic middleware structure
class RequestTimerMiddleware
def initialize(app)
@app = app
end
package api
import (
"encoding/json"
"net/http"
)
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
export interface SearchResult {
package middleware
import (
"net/http"
"sync/atomic"
)
import express, { type Express, type Request, type Response } from 'express';
export function buildApp(isShuttingDown: () => boolean): Express {
const app = express();
app.disable('x-powered-by');
package feed
import (
"encoding/base64"
"encoding/json"
"time"
package httpretry
import (
"math/rand"
"time"
)
package observability
import (
"context"
"log/slog"
"os"
package api
import (
"encoding/json"
"net/http"
)
import { z } from 'zod';
export const createUserSchema = z
.object({
email: z.string().email(),
name: z.string().min(1).max(120),