Skip to content

refactor: migrate route handlers to internal tRPC procedures#585

Open
jeevanpillay wants to merge 1 commit intomainfrom
refactor/route-handlers-to-internal-trpc
Open

refactor: migrate route handlers to internal tRPC procedures#585
jeevanpillay wants to merge 1 commit intomainfrom
refactor/route-handlers-to-internal-trpc

Conversation

@jeevanpillay
Copy link
Copy Markdown
Member

Summary

  • Move all business logic from 4 platform route handlers into internal tRPC procedures (webhooks.ingest, oauth.buildAuthorizeUrl, oauth.processCallback, oauth.pollResult)
  • Route handlers become thin HTTP adapters — zero direct DB, Redis, or lib imports
  • Fix manual err instanceof Error ternary in oauth/callback.ts with parseError()

Changes

New files:

  • api/platform/src/router/internal/webhooks.ts — webhook ingestion procedure (HMAC verification, DB persist, Inngest dispatch)
  • api/platform/src/router/internal/oauth.ts — OAuth authorize, callback, and poll procedures

Modified files:

  • api/platform/src/internal.ts — replaced ping PoC with real sub-routers (webhooks, oauth)
  • api/platform/src/lib/oauth/callback.tsparseError(err) replaces manual ternary
  • 4 route handlers slimmed to HTTP adapters delegating to platform.* procedures

Architecture

Route Handler (thin adapter)  →  Internal tRPC Procedure  →  Lib Layer
POST /api/ingest/[provider]   →  platform.webhooks.ingest()
GET  /connect/.../authorize   →  platform.oauth.buildAuthorizeUrl()
GET  /connect/.../callback    →  platform.oauth.processCallback()
GET  /connect/oauth/poll      →  platform.oauth.pollResult()

Test plan

  • pnpm --filter @api/platform typecheck passes
  • pnpm --filter @lightfast/platform typecheck passes
  • pnpm build:platform passes
  • pnpm check passes (lint/format)
  • No direct @db/app, @api/platform/lib, or Inngest client imports in route handlers
  • Webhook ingestion end-to-end (valid HMAC → 202, invalid → 401)
  • OAuth authorize/callback/poll flows work

🤖 Generated with Claude Code

Move all business logic from 4 platform route handlers into internal
tRPC procedures (webhooks.ingest, oauth.buildAuthorizeUrl,
oauth.processCallback, oauth.pollResult). Route handlers become thin
HTTP adapters that parse requests and delegate to platform.* procedures.

Also fixes manual err instanceof Error ternary in oauth/callback.ts
with parseError().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: e4e1e7876791
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightfast-app Ready Ready Preview, Comment Apr 6, 2026 10:19am
lightfast-platform Ready Ready Preview, Comment Apr 6, 2026 10:19am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
lightfast-www Skipped Skipped Apr 6, 2026 10:19am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 268575ff-3996-4a35-9257-71e29a712b87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools', 'finishing_touches'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/route-handlers-to-internal-trpc

Comment @coderabbitai help to get the list of available commands and usage tips.

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