Skip to main content

Shared libraries

The running apps import one library: libs/core (@nxt/core). Older helper and Timescale packages live under legacy/libs/ and are not part of the api / worker build.

libs/core​

Shared plumbing for both processes.

ImportWhat
@nxt/core/configloadConfig / getConfig / requireEnv — not Nest modules. Call loadConfig() before NestFactory.create.
@nxt/coreLogger, GlobalHttpModule, GlobalSupabaseModule / SupabaseService, constants, CreateCustomerDto.
@nxt/core/types/…Generated (and adjusted) Supabase types.

Do not import config from the main @nxt/core barrel — it is not re-exported there (libs/core/README.md).

JSON shape is the Zod schema in libs/core/src/config/schema.ts: $schemaVersion: "1", public.platformName, and empty capabilities / integrations until features are added. Extend that schema when you add a real flag; do not invent keys the code does not read.

That JSON is how a deployment chooses a feature set (and which vendors to use). Secrets stay in env.

Boundary rules​

  • Core: config, database client, logging, generated types. Not “all meter logic because both processes might need it.”
  • Feature modules load in api or worker AppModule when the matching config flag is on.
  • After schema changes: pnpm generate-types:local (local Supabase running). Generated files should match migrations.

Older libraries (reference only)​

  • legacy/libs/core — large historical domain dump (vendors, orders, meters, …).
  • legacy/libs/helpers — generic helpers and SQL-file loading.
  • legacy/libs/timeseries — TypeORM Timescale entities and migrations.

Do not add product features there. Bring what you need into apps/* and live libs/core.

Change management​

  • Keep @nxt/core changes additive: both processes typecheck against it.
  • If you change nxtConfigSchema, both boot paths must still parse config.default.json.
  • If you change SupabaseService or generated types, regenerate types and run nx run-many -t lint typecheck build test -p api,worker,core.

Source of truth​

  • libs/core/README.md
  • libs/core/src/index.ts, libs/core/src/config/
  • legacy/libs/