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.
| Import | What |
|---|---|
@nxt/core/config | loadConfig / getConfig / requireEnv — not Nest modules. Call loadConfig() before NestFactory.create. |
@nxt/core | Logger, 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
apiorworkerAppModulewhen 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/corechanges additive: both processes typecheck against it. - If you change
nxtConfigSchema, both boot paths must still parseconfig.default.json. - If you change
SupabaseServiceor generated types, regenerate types and runnx run-many -t lint typecheck build test -p api,worker,core.
Source of truth
libs/core/README.mdlibs/core/src/index.ts,libs/core/src/config/legacy/libs/