fix: wire admin router into main app + fix migration CLI command routing#11
Merged
munisp merged 1 commit intoJun 20, 2026
Conversation
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>
Contributor
Author
Original prompt from Patrick
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 owninitTRPC.create()— not reachable via HTTP. Now uses the shared tRPC instance (with admin role enforcement, OpenTelemetry tracing, superjson transformer) and is wired intoappRouterasadminDashboard.*.All 22 admin endpoints are now accessible at
/api/trpc/adminDashboard.{transactions,kyc,compliance,system,users,reconciliation}.*with proper auth (requiresrole === '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