Skip to content

Phase 1: Service Scaffold + Core DO #100

@eoln

Description

@eoln

Overview

Create the srv/rate-limiter/ service structure with Durable Objects implementing token bucket algorithm.

Tasks

  • Create srv/rate-limiter/ service structure
  • Configure wrangler.toml with DO binding
  • Implement Hono app with healthz endpoint
  • Create RateLimiter Durable Object class
  • Implement token bucket algorithm with Alarm API
  • Add stage isolation to DO naming
  • Add hash function for secure identifiers
  • Write unit tests for token bucket logic

Files to Create

srv/rate-limiter/
├── package.json
├── wrangler.toml
├── tsconfig.json
├── vitest.config.mts
├── src/
│   ├── index.ts              # Hono app entry
│   ├── durable-objects/
│   │   └── rate-limiter.ts   # Token bucket DO
│   ├── utils/
│   │   ├── naming.ts         # DO naming + hashing
│   │   └── token-bucket.ts   # Algorithm helpers
│   └── types.ts              # Env, policy types
└── tests/
    ├── rate-limiter.test.ts
    └── naming.test.ts

DO Naming Scheme

Format: {stage}:{type}:{subject}:{policy}

With SHA256 hashing for secrets (never embed raw API keys).

Estimate

4 hours

Parent Epic

#99

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions