-
Notifications
You must be signed in to change notification settings - Fork 2
agent: @U0AJM7X8FBR API - we want to expand our current slack integration to in #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: test
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,38 @@ import { after } from "next/server"; | |
| import { codingAgentBot } from "@/lib/coding-agent/bot"; | ||
| import "@/lib/coding-agent/handlers/registerHandlers"; | ||
|
|
||
| /** | ||
| * GET /api/coding-agent/[platform] | ||
| * | ||
| * Handles webhook verification handshakes for platforms that use GET-based challenges. | ||
| * Currently handles WhatsApp's hub.challenge verification. | ||
| * | ||
| * @param request - The incoming webhook verification request | ||
| * @param params.params | ||
| * @param params - Route params containing the platform name | ||
| */ | ||
| export async function GET( | ||
| request: NextRequest, | ||
| { params }: { params: Promise<{ platform: string }> }, | ||
| ) { | ||
| const { platform } = await params; | ||
|
|
||
| await codingAgentBot.initialize(); | ||
|
|
||
| const handler = codingAgentBot.webhooks[platform as keyof typeof codingAgentBot.webhooks]; | ||
|
|
||
| if (!handler) { | ||
| return new Response("Unknown platform", { status: 404 }); | ||
| } | ||
|
|
||
| return handler(request, { waitUntil: p => after(() => p) }); | ||
| } | ||
|
Comment on lines
+6
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Please add route coverage for the new verification branches. The new Based on learnings "Write tests for new API endpoints covering all success and error paths". Also applies to: 33-67 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * POST /api/coding-agent/[platform] | ||
| * | ||
| * Webhook endpoint for the coding agent bot. | ||
| * Currently handles Slack webhooks via dynamic [platform] segment. | ||
| * Handles Slack, WhatsApp, and GitHub webhook events via the dynamic [platform] segment. | ||
| * | ||
| * @param request - The incoming webhook request | ||
| * @param params.params | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verification fast-path is ineffective while the bot stays module-scoped.
codingAgentBotis instantiated during module import inlib/coding-agent/bot.ts:66, so these handlers still validate env and touch Redis beforeGETorPOSTruns. That makes unknown-platform requests and Slack/WhatsApp verification depend on unrelated startup state, which can turn a simple 404/challenge response into a 500 or timeout. Validateplatformfirst, then lazily create and initialize the bot only after a real handler has been selected.As per coding guidelines "All API endpoints should use a validate function for input parsing using Zod for schema validation".
Also applies to: 43-58
🤖 Prompt for AI Agents