API Testing v1

Public and JWT-authenticated REST API built with Hono, deployed on Cloudflare Workers with D1 storage.

Each table (users, products, transactions) is capped at 100 rows. Before every insert, the oldest rows are deleted automatically so the table never exceeds 100.

Base URL

All paths are relative to the deployed worker URL.

Authentication

Passwords are hashed with SHA-256 (Web Crypto). Auth endpoints issue a JWT (HS256, 24h expiry). Authenticated routes require an Authorization: Bearer <token> header.

MethodPathDescription
POST/auth/registerRegister a new user and return a JWT
POST/auth/loginLog in and return a JWT

Public API

Rate limited to 60 requests per minute per IP. No auth required.

Users

MethodPathDescription
GET/api/v1/usersList users
GET/api/v1/users/:idGet a user by ID
POST/api/v1/usersCreate a user
PUT/api/v1/users/:idUpdate a user
DELETE/api/v1/users/:idDelete a user

Products

MethodPathDescription
GET/api/v1/productsList products
GET/api/v1/products/:idGet a product by ID
POST/api/v1/productsCreate a product
PUT/api/v1/products/:idUpdate a product
DELETE/api/v1/products/:idDelete a product

Transactions

MethodPathDescription
GET/api/v1/transactionsList transactions
GET/api/v1/transactions/:idGet a transaction by ID
POST/api/v1/transactionsCreate a transaction
PUT/api/v1/transactions/:idUpdate a transaction
DELETE/api/v1/transactions/:idDelete a transaction

Authenticated API

Requires a valid JWT. Reuses the same CRUD handlers as the public routes.

Users

MethodPathDescription
GET/auth/usersList users
GET/auth/users/:idGet a user by ID
POST/auth/usersCreate a user
PUT/auth/users/:idUpdate a user
DELETE/auth/users/:idDelete a user

Products

MethodPathDescription
GET/auth/productsList products
GET/auth/products/:idGet a product by ID
POST/auth/productsCreate a product
PUT/auth/products/:idUpdate a product
DELETE/auth/products/:idDelete a product

Data models

User

FieldTypeNotes
idstring (UUID)Primary key
emailstringUnique
namestring
password_hashstringSHA-256 hash, never exposed
role'user' | 'admin'Default 'user'
created_atintegerUnix epoch milliseconds

Product

FieldTypeNotes
idstring (UUID)Primary key
namestring
descriptionstringDefault ''
pricenumberPositive
stockintegerNon-negative
created_atintegerUnix epoch milliseconds

Transaction

FieldTypeNotes
idstring (UUID)Primary key
user_idstring (UUID)
product_idstring (UUID)
quantityintegerPositive
totalnumberprice * quantity
status'pending' | 'completed' | 'cancelled'Default 'pending'
created_atintegerUnix epoch milliseconds

Rate limiting

All /api/v1/* routes use a D1-backed counter. Each IP (CF-Connecting-IP) is limited to 60 requests per minute. Limited responses include a Retry-After header.

Tools