src/synq.config.ts

Every source

src/synq.config.ts
import { sessionStore } from '@synq/next-runtime/session-store'
import { defineSynqConfig } from '@synqauth/nextjs/config'

import { BRANDS } from './examples/tour/brands.ts'

// The demo's Synq, shared by the route mount (lib/synq.ts) and the proxy.
// It serves every brand of the Synq Demo org from one deployment, a host
// each (AERO-3484, src/examples/tour/brands.ts): `resolve` answers each
// request's brand from its host, which must be one of `hosts`, and any other
// host is refused. scripts/setup-tenant.ts writes what the brands are made
// of. Deployed, the demo runs as several processes (AERO-1753), where the
// library refuses sessions in cookies alone: two replicas refreshing one
// session at once would sign the person out. So its sessions live in a store
// every replica shares, its own Valkey (SESSION_STORE_URL), sealed before
// they reach it: `keyValueSessionStore` over Valkey, which any tenant's app
// on more than one process needs too.
export const synqConfig = defineSynqConfig({
  hosts: Object.keys(BRANDS),
  resolve: ({ host }) => BRANDS[host] ?? null,
  get store() {
    return sessionStore('demo')
  },
})