Skip to content

refactor(router): extract webhook handlers into dedicated modules#482

Merged
zbigniewsobiecki merged 4 commits intodevfrom
feature/refactor-router-extract-webhook-handlers
Feb 22, 2026
Merged

refactor(router): extract webhook handlers into dedicated modules#482
zbigniewsobiecki merged 4 commits intodevfrom
feature/refactor-router-extract-webhook-handlers

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Feb 22, 2026

Summary

Refactors the src/router/index.ts god module (726 lines) by extracting provider-specific webhook handlers and shared utilities into dedicated modules.

  • Extracts shared parsing utilities into src/router/webhookParsing.ts (eliminates verbatim duplication of parseGitHubWebhookPayload between router/index.ts and server.ts, and replaces 6x copy-pasted rawHeaders extraction)
  • Extracts Trello webhook logic (9 functions + interface) into src/router/trello.ts
  • Extracts GitHub webhook logic (5 functions) into src/router/github.ts
  • Extracts JIRA webhook logic (3 functions) into src/router/jira.ts
  • Slims src/router/index.ts from 726 → ~190 lines (routing/orchestration only)
  • Adds 54 new unit tests covering all extracted modules (webhookParsing.test.ts, trello.test.ts, github.test.ts, jira.test.ts)

Test plan

  • All 54 new unit tests pass
  • Full test suite: only 6 pre-existing failures (unrelated config/projects.test.ts), no regressions
  • TypeScript: zero errors (npm run typecheck)
  • Lint: zero errors (npm run lint)

Card

https://trello.com/c/p8olsrA4/73-refactor-router-indexts-extract-webhook-handlers-deduplicate

🤖 Generated with Claude Code

@zbigniewsobiecki zbigniewsobiecki changed the base branch from main to dev February 22, 2026 16:53
Use handleTrelloWebhook() as the single entry point (matching GitHub/JIRA
pattern), merge duplicate ./trello.js imports, and split misleading test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nhopeatall
Copy link
Copy Markdown
Collaborator

🔍 Reviewing PR...

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean extraction refactor that breaks a 726-line god module into well-bounded provider-specific modules with proper dependency injection (triggerRegistry as parameter instead of closure capture). Verified behavioral equivalence of extracted code, confirmed deduplication of parseGitHubWebhookPayload between router and server, and all 55 new tests pass with zero TypeScript errors.

@zbigniewsobiecki zbigniewsobiecki merged commit 4223e42 into dev Feb 22, 2026
5 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the feature/refactor-router-extract-webhook-handlers branch March 16, 2026 16:43
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.

3 participants