From fdfef2d25411937984ad5ac4ad8af7ac2ca0e271 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 12 Mar 2025 00:49:29 -0700 Subject: [PATCH] fix: remove unused workflow/[id] routeand util functions --- app/api/workflow/[id]/route.ts | 72 ---------------------------------- lib/workflows.ts | 21 ---------- 2 files changed, 93 deletions(-) delete mode 100644 app/api/workflow/[id]/route.ts diff --git a/app/api/workflow/[id]/route.ts b/app/api/workflow/[id]/route.ts deleted file mode 100644 index 7504cad03d..0000000000 --- a/app/api/workflow/[id]/route.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { NextRequest } from 'next/server' -import { createLogger } from '@/lib/logs/console-logger' -import { Executor } from '@/executor' -import { SerializedWorkflow } from '@/serializer/types' -import { validateWorkflowAccess } from '../middleware' -import { createErrorResponse, createSuccessResponse } from '../utils' - -const logger = createLogger('WorkflowAPI') - -export const dynamic = 'force-dynamic' - -async function executeWorkflow(workflow: any, requestId: string, input?: any) { - try { - logger.info(`[${requestId}] Executing workflow: ${workflow.id}`) - const executor = new Executor(workflow.state as SerializedWorkflow, input) - const result = await executor.execute(workflow.id) - - logger.info(`[${requestId}] Workflow execution completed: ${workflow.id}`, { - success: result.success, - }) - - return result - } catch (error: any) { - logger.error(`[${requestId}] Workflow execution failed: ${workflow.id}`, error) - throw new Error(`Execution failed: ${error.message}`) - } -} - -export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) { - const requestId = crypto.randomUUID().slice(0, 8) - - try { - const { id } = await params - logger.debug(`[${requestId}] GET request for workflow: ${id}`) - - const validation = await validateWorkflowAccess(request, id) - - if (validation.error) { - logger.warn(`[${requestId}] Workflow access validation failed: ${validation.error.message}`) - return createErrorResponse(validation.error.message, validation.error.status) - } - - const result = await executeWorkflow(validation.workflow, requestId) - return createSuccessResponse(result) - } catch (error: any) { - logger.error(`[${requestId}] Error executing workflow: ${(await params).id}`, error) - return createErrorResponse('Failed to execute workflow', 500, 'EXECUTION_ERROR') - } -} - -export async function POST(request: NextRequest, { params }: { params: Promise<{ id: string }> }) { - const requestId = crypto.randomUUID().slice(0, 8) - - try { - const { id } = await params - logger.debug(`[${requestId}] POST request for workflow: ${id}`) - - const validation = await validateWorkflowAccess(request, id) - - if (validation.error) { - logger.warn(`[${requestId}] Workflow access validation failed: ${validation.error.message}`) - return createErrorResponse(validation.error.message, validation.error.status) - } - - const body = await request.json().catch(() => ({})) - const result = await executeWorkflow(validation.workflow, requestId, body) - return createSuccessResponse(result) - } catch (error: any) { - logger.error(`[${requestId}] Error executing workflow: ${(await params).id}`, error) - return createErrorResponse('Failed to execute workflow', 500, 'EXECUTION_ERROR') - } -} diff --git a/lib/workflows.ts b/lib/workflows.ts index 4cfe2b03eb..e4e39fde8c 100644 --- a/lib/workflows.ts +++ b/lib/workflows.ts @@ -7,24 +7,3 @@ export async function getWorkflowById(id: string) { return workflows[0] } - -export async function updateWorkflowDeploymentStatus( - id: string, - isDeployed: boolean, - apiKey?: string -) { - return db - .update(workflowTable) - .set({ - isDeployed, - deployedAt: isDeployed ? new Date() : null, - updatedAt: new Date(), - apiKey: apiKey || null, - }) - .where(eq(workflowTable.id, id)) -} - -export function getWorkflowEndpoint(id: string) { - const baseUrl = process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000' - return `${baseUrl}/api/workflow/${id}` -}