ObjectStackObjectStack

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 { CorsConfigSchema, HttpMethod, HttpMethodSubsetSchema, HttpRequestSchema, RateLimitConfigSchema, StaticMountSchema } from '@objectstack/spec/shared';
import type { CorsConfig, HttpMethod, HttpMethodSubset, HttpRequest, RateLimitConfig, StaticMount } from '@objectstack/spec/shared';

// Validate data
const result = CorsConfigSchema.parse(data);

CorsConfig

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable CORS
originsstring | string[]Allowed origins (* for all)
methodsEnum<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'>[]optionalAllowed HTTP methods
credentialsbooleanAllow credentials (cookies, authorization headers)
maxAgeintegeroptionalPreflight cache duration in seconds

HttpMethod

HTTP method — the full routing vocabulary (api/* endpoints, router and REST-server routes). The narrower HttpMethodSubset is what view data sources may request.

Allowed Values

  • GET
  • POST
  • PUT
  • DELETE
  • PATCH
  • HEAD
  • OPTIONS

HttpMethodSubset

HTTP methods a view data source may request — the subset of HttpMethod without HEAD/OPTIONS.

Allowed Values

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

HttpRequest

Properties

PropertyTypeRequiredDescription
urlstringAPI endpoint URL
methodEnum<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'>HTTP method
headersRecord<string, string>optionalCustom HTTP headers
paramsRecord<string, any>optionalQuery parameters
bodyanyoptionalRequest body for POST/PUT/PATCH

RateLimitConfig

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable rate limiting
windowMsintegerTime window in milliseconds
maxRequestsintegerMax requests per window

StaticMount

Properties

PropertyTypeRequiredDescription
pathstringURL path to serve from
directorystringPhysical directory to serve
cacheControlstringoptionalCache-Control header value

On this page