mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
fc7d8b5d12
Brownfield strangler migration of the backend onto NestJS modules (auth, trips, days, places, assignments, packing, todo, budget, reservations, collab, files, photos, journey, share, settings, backup, oidc, oauth, admin, atlas, vacay, weather, airports, maps, categories, tags, notifications, system-notices) served through a per-prefix dispatcher, keeping the existing SQLite/better-sqlite3 DB and JWT httpOnly cookie auth, with behavioural parity for every route. Client: React 19 upgrade, "page = wiring container + data hook" pattern across all pages, per-domain Zustand stores bound to @trek/shared contracts, and decomposition of the large components (DayPlanSidebar, PackingListPanel, CollabNotes, FileManager, MemoriesPanel, PlacesSidebar, CollabChat, SystemNoticeModal, BudgetPanel, PlaceFormModal, ...) into focused render units backed by in-file hooks. Apply the shared global request pipeline (helmet/CSP, CORS, HSTS, forced HTTPS, the global MFA policy and request logging) to the NestJS instance as well, so a migrated route is protected identically to the legacy fallback rather than bypassing it.
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
// Boots the TREK backend for the Playwright E2E run against a fresh, isolated
|
|
// SQLite database. The DB file is deleted first so every run starts clean, then
|
|
// the server's own startup seeds a known admin from ADMIN_EMAIL/ADMIN_PASSWORD.
|
|
//
|
|
// The server is built once and launched as a SINGLE node process (not the
|
|
// watch-mode `npm run dev`, which spawns tsc -w + node --watch grandchildren
|
|
// that survive Playwright's teardown and then linger on :3001 with stale DB
|
|
// state). A single child is killed cleanly when Playwright tears the run down.
|
|
import { rmSync } from 'node:fs'
|
|
import { spawn, execSync } from 'node:child_process'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
const dbFile = path.join(here, '.tmp', 'e2e.db')
|
|
const serverDir = path.join(here, '..', '..', 'server')
|
|
|
|
for (const f of [dbFile, `${dbFile}-wal`, `${dbFile}-shm`]) {
|
|
try { rmSync(f, { force: true }) } catch {}
|
|
}
|
|
|
|
// Build once (no watcher) — the resulting process is a single killable node.
|
|
execSync('node scripts/build.mjs', { cwd: serverDir, stdio: 'inherit' })
|
|
|
|
const env = {
|
|
...process.env,
|
|
TREK_DB_FILE: dbFile,
|
|
ADMIN_EMAIL: 'e2e@trek.local',
|
|
ADMIN_PASSWORD: 'E2eTest12345!',
|
|
PORT: '3001',
|
|
NODE_ENV: 'development',
|
|
}
|
|
|
|
const child = spawn(process.execPath, ['--require', 'tsconfig-paths/register', 'dist/index.js'], {
|
|
cwd: serverDir,
|
|
env,
|
|
stdio: 'inherit',
|
|
})
|
|
const stop = () => { try { child.kill() } catch {} }
|
|
process.on('SIGINT', stop)
|
|
process.on('SIGTERM', stop)
|
|
process.on('exit', stop)
|
|
child.on('exit', code => process.exit(code ?? 0))
|