mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
0b218d53b2
Co-hosted NestJS app behind the existing Express server via a strangler-fig dispatcher, sharing the same better-sqlite3 connection and JWT httpOnly cookie. Additive and dormant: default routing stays on Express, Nest only serves its own /api/_nest diagnostics until a module opts in. F1 @trek/shared Zod contract package; F2 Nest bootstrap co-hosted (fall-through, single Dockerfile/port); F3 shared better-sqlite3 provider; F4 JWT cookie auth guard (+ @CurrentUser, admin guard); F5 Zod validation pipe + error-envelope parity; F6 Nest test + coverage gates; F7 per-prefix strangler toggle (env, default Express); F8 CI build/typecheck/test/coverage. Remaining F4/F6/F8 checklist items (trip-access + permission levels + MFA policy, e2e harness/seed + 80% gate, Nest↔Express parity test, Playwright PR-comment workflow) are tracked on the first consuming module cards (L1/A1/C1).
33 lines
1.4 KiB
Markdown
33 lines
1.4 KiB
Markdown
# @trek/shared
|
|
|
|
Single source of truth for TREK's API contracts, expressed as [Zod](https://zod.dev) schemas
|
|
and consumed by **both** the server (request validation + inferred DTO types) and the client
|
|
(typed requests/responses).
|
|
|
|
This package is part of the incremental NestJS + React 19 migration
|
|
(see the "Brownfield Rewrite" board). It is intentionally **dormant** until modules start
|
|
importing it — adding it changes nothing for users.
|
|
|
|
## Rules
|
|
|
|
- **One folder per domain**: `src/<domain>/<domain>.schema.ts` (+ `.spec.ts`).
|
|
- Domain-agnostic building blocks live in `src/common/`.
|
|
- A route is only considered **migrated** once its contract lives here.
|
|
- Schemas are the source of truth; server DTOs and client types are *inferred* from them
|
|
(`z.infer<typeof schema>`), never hand-duplicated.
|
|
|
|
## Consumption (dev)
|
|
|
|
Both apps resolve `@trek/shared` to this package's TypeScript source:
|
|
|
|
- **Server** (`tsx`): via `paths` in `server/tsconfig.json`.
|
|
- **Client** (`vite`): via `resolve.alias` in `client/vite.config.ts` (+ `paths` for the type-checker).
|
|
|
|
> Production packaging (Docker / workspace wiring) is introduced in card **F2**, when the
|
|
> server first depends on this package at runtime. Until then prod builds are untouched.
|
|
|
|
## Not yet here
|
|
|
|
The canonical **error envelope** is finalised in card **F5** (it must match TREK's current
|
|
Express error responses byte-for-byte), so it is deliberately not invented in F1.
|