Skip to content

fix: wire admin router into main app + fix migration CLI command routing#11

Merged
munisp merged 1 commit into
devin/1779302835-typescript-strict-fixesfrom
devin/1781956754-fix-escalations
Jun 20, 2026
Merged

fix: wire admin router into main app + fix migration CLI command routing#11
munisp merged 1 commit into
devin/1779302835-typescript-strict-fixesfrom
devin/1781956754-fix-escalations

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Fixes two escalations found during PR #10 testing:

1. Migration CLI (drizzle/migrate.ts): getPool() was called before command routing, so commands that don't need a database (generate, invalid commands) failed with "DATABASE_URL required" instead of showing their intended output.

 async function main() {
   const command = process.argv[2] || "status";
-  const pool = await getPool();
-  try {
-    switch (command) {
-      case "generate": ...
-      default: ...
-    }
+  if (command === "generate") { /* print instructions, return */ }
+  if (!["up", "down", "status"].includes(command)) { /* show usage, exit 1 */ }
+  const pool = await getPool(); // Only connect for commands that need DB
+  try { switch (command) { ... } }

2. Admin Router (server/admin/adminRouter.ts): Was a standalone module with its own initTRPC.create() — not reachable via HTTP. Now uses the shared tRPC instance (with admin role enforcement, OpenTelemetry tracing, superjson transformer) and is wired into appRouter as adminDashboard.*.

All 22 admin endpoints are now accessible at /api/trpc/adminDashboard.{transactions,kyc,compliance,system,users,reconciliation}.* with proper auth (requires role === 'admin').

Verification: 0 TypeScript errors, 1555/1559 tests passing (4 pre-existing failures unrelated to this change).

Link to Devin session: https://app.devin.ai/sessions/64d054ae77da41e9a2b74d8593fa635c
Requested by: @munisp

Two escalations from PR #10 testing:

1. Migration CLI (drizzle/migrate.ts):
   - Moved getPool() AFTER command routing
   - 'generate' now prints instructions without requiring DATABASE_URL
   - Invalid commands show usage message instead of DB connection error
   - up/down/status still correctly require DATABASE_URL

2. Admin Router (server/admin/adminRouter.ts):
   - Replaced standalone initTRPC.create() with shared instance from _core/trpc
   - Uses the app's adminProcedure (role check + tracing + context)
   - Wired into main appRouter as 'adminDashboard' namespace
   - All 22 endpoints now accessible via /api/trpc/adminDashboard.*

Co-Authored-By: Patrick Munis <pmunis@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from Patrick

https://drive.google.com/file/d/14K-94cZoOVgiYCUA-VympU-4_8IBqv2d/view?usp=sharing
extract the contents of the archive. List all the features of the platform

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@munisp munisp merged commit b7e0ab2 into devin/1779302835-typescript-strict-fixes Jun 20, 2026
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.

1 participant