S
Store

Configuration Reference

StoreConfig, StoreProfile, schema, routes, sync, encryption, and environment options.

Config file

Application code passes a StoreConfig object to createStore(). You can keep that object in store.config.ts, JSON, or any other app-owned configuration source.

import type { StoreConfig } from "@cuitty/store/client";

export default {
  module: "my-app",
  profile: {
    id: "local-dev",
    name: "Local Dev",
    local: { adapter: "local.sqlite", path: ".cuitty/store/dev.sqlite" },
    remotes: [],
    routes: [],
    encryption: { atRest: "disabled", remote: "disabled", p2p: "disabled" },
    sync: { mode: "manual" },
  },
  schema: {
    users: { class: "record" },
    audit: { class: "event" },
    media: { class: "blob" },
  },
  actorId: "device:local",
} satisfies StoreConfig;

Profile configuration

Profiles define local storage, remote targets, route rules, encryption policy, and sync policy.

export default {
  module: "team-app",
  profile: {
    id: "team",
    name: "Team Workspace",
    local: {
      adapter: "local.sqlite",
      path: ".cuitty/store/team.sqlite",
    },
    remotes: [
      {
        id: "team-postgres",
        adapter: "postgres.record",
        dsnRef: "secret://store/postgres/url",
      },
      {
        id: "media-bucket",
        adapter: "s3.blob",
        bucket: "my-assets",
      },
    ],
    routes: [
      { namespace: "users", class: "record", localAdapter: "local.sqlite", remoteAdapters: ["team-postgres"] },
      { namespace: "media", class: "blob", localAdapter: "local.cas", remoteAdapters: ["media-bucket"] },
    ],
    encryption: { atRest: "required", remote: "required", p2p: "required" },
    sync: { mode: "manual" },
  },
};

See the Adapter Matrix for exact adapter IDs and supported storage classes.

Schema configuration

export default {
  schema: {
    users: {
      class: "record",
      primaryKey: ["id"],
      indexes: [{ name: "users_by_email", fields: ["email"], kind: "value" }],
    },
    audit: { class: "event" },
    media: { class: "blob" },
  },
};

Sync configuration

Sync settings live on the active profile.

export default {
  profile: {
    // ...
    sync: {
      mode: "manual", // "manual" | "opportunistic" | "continuous" | "scheduled" | "disabled"
      flushEveryMs: 10_000,
      maxBatchBytes: 1_000_000,
    },
  },
};

Encryption configuration

export default {
  profile: {
    // ...
    encryption: {
      atRest: "required",
      remote: "required",
      p2p: "required",
    },
  },
};

Retention configuration

Retention applies per route.

export default {
  profile: {
    // ...
    routes: [
      {
        namespace: "audit",
        class: "event",
        localAdapter: "local.sqlite",
        remoteAdapters: ["team-postgres"],
        retention: { deleteAfterDays: 90, requireTombstoneSync: true },
      },
    ],
  }
};

Environment variables

VariableDescriptionDefault
STORE_APP_PROFILE_PATHJSON profile path for the app/server runtimenone
STORE_APP_SCHEMA_PATHOptional JSON schema path for the app/server runtimenone
STORE_APP_MODULEModule name overridestore_app
STORE_APP_ACTOR_IDActor ID overridestore_app:server
STORE_APP_DEMO_MODEAllows the built-in demo profile when no profile path is configuredunset