Files
template-app/apps/worker/src/runtime.ts
T
2026-11-14 09:56:45 +00:00

25 lines
1.1 KiB
TypeScript

// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
// The worker's composition root for what runs beside `createPostgresWorker` (spec §2): this app's modules
// and ports on `@conusai-kit/host/worker`. The seed job builds on it.
import { type AppEnv, businessServiceComposition, type ServerObservability } from "@app/config"
import { appModules } from "@app/modules"
import { buildPostgresWorkerRuntime, type WorkerRuntime } from "@conusai-kit/host/worker"
import { bindModulePorts, nativeHelpSelectors } from "./ports.js"
export type { WorkerRuntime }
export function buildWorkerRuntime(env: AppEnv, observe: ServerObservability): WorkerRuntime {
const postgres = env.postgres
if (!postgres) throw new Error("The selected profile has no Postgres worker")
const runtime = buildPostgresWorkerRuntime({ modules: appModules, env: { ...env, postgres }, observe })
bindModulePorts(
runtime.container,
runtime.platform,
runtime.registry,
businessServiceComposition(env, appModules, "postgres", { model: runtime.platform.model, ...nativeHelpSelectors })
.serviceReadiness,
)
return runtime
}