Перейти к основному содержимому

REST API patterns (pagination, envelopes, rate limits)

Generated from pattern-library/registry.json — do not edit by hand; change the registry and run bun run patterns:build.

Index card — the docs below are the canonical explanation; deep-tier pattern pages additionally carry invariants and emulation notes.

Category: Architecture & Request Pipeline · Tier: light · Maturity: proven (verified 2026-08-20 @ 1a130d67) · Risk: low — structural pattern, no external services

Defines the file-based +server.ts convention for REST endpoints, covering Valibot validation, error() status codes, pagination, and response envelopes.

When to use: Reach for it when building a new REST or SSE endpoint under src/routes/api/.

Docs

Code

Tests

  • src/lib/api.gate.test.ts — Client fetches to /api must ride apiFetch (CSRF header) (GitHub · GitLab)
  • src/lib/server/http/body.test.ts (GitHub · GitLab)
  • src/lib/server/http/rate-limit.test.ts (GitHub · GitLab)

Machine-readable record: architecture-rest-api in pattern-library/registry.json.

← Back to Pattern Library

Думаете, этот паттерн можно сделать лучше? Расскажите как.

Оставить отзыв