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 { 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

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

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