learn
packages/

Backend common

Server-only collaboration and access operations shared by HTTP, WebSocket, and worker apps.

There is exactly one write path for room data, and all three backend services use it: the commit is checked against the caller's role, replayed mutations are dropped, the batch is validated and reconciled, and the result lands in the live store, falling back to the database when Redis is unavailable.

What it owns

  • Applying room commits: roles, dedupe, validation, reconcile, persist
  • Attaching image files to scenes within size and count caps
  • Reading the sync head for snapshots, warming the live store
  • Shared WebSocket transport helpers: heartbeat, origins, limits, close codes

Files

File list and purposes from the folder README.

FilePurpose
src/collaboration.tsCommit, file-attach, and sync-read operations.
src/presenceTransport.tsHelpers shared by the HTTP ticket issuer and the presence server.
src/index.tsPackage entry.

Dependencies

LibraryVersion rangeWhy it is used here
dotenvDeclared but not used in source^17.4.2Loads local environment files in development.
Development and tooling (2)
LibraryVersion rangeWhy it is used here
TypeScript type definitions@types/node26.4.1Type declarations for the packages used here.
Vitest^5.0.1Runs the unit and regression test suites.

Dependencies as of commit b0026d9.

backend-common package
BrowserAPIRealtimeCacheDatabaseShareddurableephemeral

Talks to

Sources: packages/backend-common/README.md, packages/backend-common/src/README.md, packages/backend-common/src/collaboration.ts, packages/backend-common/src/presenceTransport.ts (documented at commit b0026d9)

On this page