Skip to content

fix: local dev startup — circular dep + missing scripts (#87)#89

Merged
telivity-otaip merged 1 commit into
mainfrom
fix/issue-87-startup
Apr 23, 2026
Merged

fix: local dev startup — circular dep + missing scripts (#87)#89
telivity-otaip merged 1 commit into
mainfrom
fix/issue-87-startup

Conversation

@telivity-otaip
Copy link
Copy Markdown
Collaborator

Fixes #87.

Summary

Three problems reported by a new developer trying to boot HAIP locally:

1. `ChannelAdapterFactory` circular import crash

`pnpm dev` crashed with `ReferenceError: Cannot access 'ChannelAdapterFactory' before initialization`. Cycle:

```
channel-adapter.factory.ts
→ ./adapters/booking-com (barrel index)
→ BookingComInboundController
→ inbound-reservation.service
→ ChannelAdapterFactory ❌ cycle
```

The barrel index re-exports the inbound controller alongside the adapter, so importing the adapter from the barrel pulls controller wiring into factory module init.

Fix: `channel-adapter.factory.ts` and `channel.module.ts` now import `BookingComAdapter` and `SiteMinderAdapter` directly from their `.adapter.ts` files, bypassing the barrel. Inline comments document why.

2. Missing `migrate` / `seed` scripts

README called `pnpm --filter @telivityhaip/api run migrate|seed` but those scripts lived on `@telivityhaip/database` (or didn't exist). Also, `db:migrate` pointed at `drizzle-kit migrate` which expects pre-generated SQL that isn't checked in.

Fix:

  • Added `"migrate": "tsx src/push-schema.ts"` to `packages/database/package.json`
  • Redirected `db:migrate` to the same (drizzle-kit migrate is a dead end without generated SQL files)
  • README now uses the correct filter: `pnpm --filter @telivityhaip/database run migrate|seed`

3. README verification

Walked the full Quick Start flow. All steps now work end-to-end.

Test plan

  • `pnpm dev` — `Nest application successfully started`, API on localhost:3000
  • `pnpm --filter @telivityhaip/database run migrate` — `Schema pushed successfully`
  • `pnpm -w build` green
  • `pnpm -w typecheck` green
  • `pnpm -w test` — 575/575
  • `pnpm --filter @telivityhaip/api lint` — 0 errors

🤖 Generated with Claude Code

1. ChannelAdapterFactory circular import crash
   Cycle: factory → adapters/booking-com (barrel) → inbound-controller
   → inbound-reservation.service → factory.
   The barrel re-exports BookingComInboundController, pulling runtime
   controller wiring into the factory's module init.
   Fix: factory and channel.module import adapters directly from their
   .adapter.ts files, bypassing the barrel.

2. Missing migrate/seed scripts
   README called `pnpm --filter @telivityhaip/api run migrate|seed` but
   those scripts live on @telivityhaip/database (or didn't exist at all).
   Added `"migrate": "tsx src/push-schema.ts"` to the database package
   and redirected db:migrate to the same (drizzle-kit migrate required
   pre-generated SQL files that weren't there).
   Updated README to call the correct filter.

Verified: API starts cleanly (`Nest application successfully started`),
575/575 tests pass, build + typecheck + lint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@telivity-otaip telivity-otaip merged commit a3c9122 into main Apr 23, 2026
3 checks passed
@telivity-otaip telivity-otaip deleted the fix/issue-87-startup branch April 23, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Local development instructions outdated; missing scripts; API fails to start due to circular dependency

1 participant