Http
Http protocol schemas
Shared HTTP Schemas
Common HTTP-related schemas used across API and System protocols.
These schemas ensure consistency across different parts of the stack.
Source: packages/spec/src/shared/http.zod.ts
TypeScript Usage
import { CorsConfig, HttpMethod, HttpRequest, RateLimitConfig, StaticMount } from '@objectstack/spec/shared';
import type { CorsConfig, HttpMethod, HttpRequest, RateLimitConfig, StaticMount } from '@objectstack/spec/shared';
// Validate data
const result = CorsConfig.parse(data);CorsConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable CORS |
| origins | string | string[] | ✅ | Allowed origins (* for all) |
| methods | Enum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>[] | optional | Allowed HTTP methods |
| credentials | boolean | ✅ | Allow credentials (cookies, authorization headers) |
| maxAge | integer | optional | Preflight cache duration in seconds |
HttpMethod
Allowed Values
GETPOSTPUTPATCHDELETE
HttpRequest
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | ✅ | API endpoint URL |
| method | Enum<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'> | ✅ | HTTP method |
| headers | Record<string, string> | optional | Custom HTTP headers |
| params | Record<string, any> | optional | Query parameters |
| body | any | optional | Request body for POST/PUT/PATCH |
RateLimitConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable rate limiting |
| windowMs | integer | ✅ | Time window in milliseconds |
| maxRequests | integer | ✅ | Max requests per window |
StaticMount
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| path | string | ✅ | URL path to serve from |
| directory | string | ✅ | Physical directory to serve |
| cacheControl | string | optional | Cache-Control header value |