forked from claude-did-this/claude-hub
* feat: Implement modular webhook architecture for multi-provider support - Add generic webhook types and interfaces for provider-agnostic handling - Create WebhookRegistry for managing providers and event handlers - Implement WebhookProcessor for unified webhook request processing - Add GitHubWebhookProvider implementing the new interfaces - Create new /api/webhooks/:provider endpoint supporting multiple providers - Update GitHub types to include missing id, email, and merged_at properties - Add comprehensive unit tests for all webhook components - Maintain backward compatibility with existing /api/webhooks/github endpoint This architecture enables easy addition of new webhook providers (GitLab, Bitbucket, etc.) while keeping the codebase modular and maintainable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * security: Implement webhook security enhancements - Add provider name validation against whitelist to prevent arbitrary provider injection - Implement generic error messages to avoid information disclosure - Make webhook signature verification mandatory in production environments - Fix linter warnings in GitHubWebhookProvider.ts - Add comprehensive security tests Security improvements address: - Input validation: Provider names validated against ALLOWED_WEBHOOK_PROVIDERS - Error disclosure: Generic messages replace detailed error information - Authentication: Signature verification cannot be skipped in production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Fetch complete PR details for manual review commands When processing @MCPClaude review commands on PR comments, the webhook payload only contains minimal PR information. This fix ensures we fetch the complete PR details from GitHub API to get the correct head/base refs and SHA, preventing the "unknown" branch issue. Also fixes test initialization issue in webhooks.test.ts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Fix failing webhook route tests in CI The webhook route tests were failing because the mock for the GitHub provider module was incomplete. Updated the mock to include the initializeGitHubProvider function to prevent import errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Move Jest mocks before imports to prevent auto-initialization The webhook tests were failing in CI because the GitHub provider mock was declared after the imports, allowing the auto-initialization to run. Moving all mocks to the top of the file ensures they are in place before any module loading occurs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Mock webhook registry to prevent auto-initialization in tests The webhook route tests were failing because the webhook registry was being imported and triggering auto-initialization. By fully mocking the webhook registry module before any imports, we prevent side effects and ensure tests run in isolation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Properly mock WebhookProcessor to avoid module initialization issues The webhook route tests were failing in CI due to differences in module loading between Node.js versions. By mocking the WebhookProcessor class and moving imports after mocks are set up, we ensure consistent behavior across environments. The mock now properly simulates the authorization logic to maintain test coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Remove side effects from webhook module initialization The webhook tests were failing in CI because the GitHub provider was being auto-initialized during module import, causing unpredictable behavior across different Node.js versions and environments. Changes: - Moved provider initialization to dynamic import in non-test environments - Simplified webhook route tests to avoid complex mocking - Removed unnecessary mocks that were testing implementation details This ensures deterministic test behavior across all environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Fix webhook tests mock configuration for secureCredentials The webhook tests were failing with "secureCredentials.get is not a function" because the mock wasn't properly configured for ES module default exports. Changes: - Added __esModule: true to the mock to properly handle default exports - Removed debugging code from tests - Tests now pass consistently in all environments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
11 lines
336 B
TypeScript
11 lines
336 B
TypeScript
import express from 'express';
|
|
import { handleWebhook } from '../controllers/githubController';
|
|
|
|
const router = express.Router();
|
|
|
|
// Legacy GitHub webhook endpoint - maintained for backward compatibility
|
|
// New webhooks should use /api/webhooks/github
|
|
router.post('/', handleWebhook as express.RequestHandler);
|
|
|
|
export default router;
|