Libraries v5.0.0
    Preparing search index...

    Module contract

    Browser-safe entry point for @cleverbrush/server.

    Re-exports the endpoint builder, factory functions and type helpers needed to define API contracts without pulling in the Node.js server runtime. Use this entry point in shared packages that are consumed by both the backend (Node.js) and the frontend (browser).

    import { defineApi, endpoint, route } from '@cleverbrush/server/contract';
    import { array, number, object, string } from '@cleverbrush/schema';

    const TodoSchema = object({ id: number(), title: string() });

    export const api = defineApi({
    todos: {
    list: endpoint.resource('/api/todos').get()
    .responses({ 200: array(TodoSchema) }),
    get: endpoint.resource('/api/todos').get(
    route({ id: number().coerce() })`/${t => t.id}`
    ).responses({ 200: TodoSchema }),
    },
    });
    ApiContract
    ApiGroup
    MergedContracts
    defineApi
    mergeContracts
    omitGroups
    pickGroups
    ActionContext → ActionContext
    AllowedResponseReturn → AllowedResponseReturn
    CacheTagDefinition → CacheTagDefinition
    CacheTagPropertyAccessor → CacheTagPropertyAccessor
    CallbackDefinition → CallbackDefinition
    computeCacheKey → computeCacheKey
    createEndpoints → createEndpoints
    endpoint → endpoint
    EndpointBuilder → EndpointBuilder
    EndpointMetadata → EndpointMetadata
    EndpointMetadataDescriptors → EndpointMetadataDescriptors
    file → file
    FilePart → FilePart
    Handler → Handler
    LinkDefinition → LinkDefinition
    PropertyRefTree → PropertyRefTree
    ResponsesOf → ResponsesOf
    route → route
    ScopedEndpointFactory → ScopedEndpointFactory
    SubscriptionBuilder → SubscriptionBuilder
    SubscriptionContext → SubscriptionContext
    SubscriptionHandler → SubscriptionHandler
    SubscriptionHandlerEntry → SubscriptionHandlerEntry
    SubscriptionMetadata → SubscriptionMetadata
    tracked → tracked
    TrackedEvent → TrackedEvent
    UploadConfiguration → UploadConfiguration
    UploadContract → UploadContract
    UploadFiles → UploadFiles
    UploadOptions → UploadOptions
    UploadSchema → UploadSchema