Restate Typescript SDK
    Preparing search index...

    Options for creating an endpoint handler.

    interface TestEnvironmentOptions {
        alwaysReplay?: boolean;
        container?: () => GenericContainer;
        defaultServiceOptions?: DefaultServiceOptions;
        disableRetries?: boolean;
        identityKeys?: string[];
        journalValueCodecProvider?: () => Promise<JournalValueCodec>;
        logger?: LoggerTransport;
        serviceEndpointAccess?: ServiceEndpointAccess;
        services: (
            | ServiceDefinition<string, unknown>
            | VirtualObjectDefinition<string, unknown>
            | WorkflowDefinition<string, unknown>
        )[];
        storage?: TestEnvironmentStorage;
    }

    Hierarchy (View Summary)

    Index

    Properties

    alwaysReplay?: boolean

    Forces restate-server to always replay on a suspension point. This is useful to hunt non-deterministic bugs that might prevent your code from replaying correctly.

    container?: () => GenericContainer

    Factory for the Restate container used by the test environment.

    Use this to customize the Restate image or container settings before the helper applies its own ports, wait strategy, networking, and storage configuration.

    For backwards compatibility, the second start(options, factory) argument is still supported and takes precedence over this option.

    () => new RestateContainer()

    defaultServiceOptions?: DefaultServiceOptions

    Default service options that will be used by all services bind to this endpoint.

    Options can be overridden on each service/handler.

    disableRetries?: boolean

    Disables retries in the restate-server invoker. This is useful in tests so that failures surface immediately instead of hanging through retry backoff.

    identityKeys?: string[]

    Provide a list of v1 request identity public keys eg publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9 to validate incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is logged by the Restate process at startup if a request identity private key is provided.

    If this function is called, all incoming requests irrelevant of endpoint type will be expected to have x-restate-signature-scheme: v1 and x-restate-jwt-v1: <valid jwt signed with one of these keys>. If not called,

    journalValueCodecProvider?: () => Promise<JournalValueCodec>

    Provider for the codec to use for journal values. One codec will be instantiated globally for this endpoint. Check JournalValueCodec for more details

    Replace the default console-based LoggerTransport

    Using console:

    createEndpointHandler({ logger: (meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)}})
    

    Using winston:

    const logger = createLogger({ ... })
    createEndpointHandler({ logger: (meta, message, ...o) => {logger.log(meta.level, {invocationId: meta.context?.invocationId}, [message, ...o].join(' '))} })

    Using pino:

    const logger = pino()
    createEndpointHandler({ logger: (meta, message, ...o) => {logger[meta.level]({invocationId: meta.context?.invocationId}, [message, ...o].join(' '))}} )
    serviceEndpointAccess?: ServiceEndpointAccess

    Controls how the Restate container reaches the SDK service endpoint running on the test host.

    • "testcontainers" exposes the host port through Testcontainers and registers http://host.testcontainers.internal:<port>.
    • "docker-host" skips Testcontainers port exposure, adds host.docker.internal:host-gateway to the Restate container, and registers http://host.docker.internal:<port>.

    "docker-host"

    services: (
        | ServiceDefinition<string, unknown>
        | VirtualObjectDefinition<string, unknown>
        | WorkflowDefinition<string, unknown>
    )[]

    A list of Restate services, virtual objects, or workflows that will be exposed via the endpoint.

    Controls where Restate stores container data.

    • "disk" keeps the current Testcontainers/Docker storage behavior.
    • "memory" mounts /restate-data as tmpfs for faster disposable tests.

    "memory"