diff --git a/app/api/generate/route.ts b/app/api/generate/route.ts index 12fcd0c..99e75fa 100644 --- a/app/api/generate/route.ts +++ b/app/api/generate/route.ts @@ -30,7 +30,7 @@ export async function POST(request: NextRequest) { // // Repair the generated code using Benchify's API const { repairedFiles, buildOutput } = await repairCode(validatedFiles); - + const { sbxId, template, url } = await createSandbox({ files: generatedFiles }); console.log("Preview URL: ", url); diff --git a/lib/benchify.ts b/lib/benchify.ts index 3c35a13..dbb6946 100644 --- a/lib/benchify.ts +++ b/lib/benchify.ts @@ -18,7 +18,7 @@ if (!BENCHIFY_API_KEY) { export async function repairCode(files: z.infer): Promise<{ repairedFiles: z.infer, buildOutput: string }> { try { // Simple build command to verify syntax - const buildCmd = "npm run dev"; + const buildCmd = "npx vite build"; // Validate request against Benchify API schema const requestData = benchifyRequestSchema.parse({ @@ -71,7 +71,7 @@ export async function repairCode(files: z.infer): Pro const parsedFiles = benchifyFileSchema.parse(files); const repairedFiles = parsedFiles.map(file => { if (result.diff) { - const patchResult = applyPatch(file.contents, result.diff); + const patchResult = applyPatch(file.content, result.diff); return { path: file.path, content: typeof patchResult === 'string' ? patchResult : file.content diff --git a/lib/e2b.ts b/lib/e2b.ts index fbdad0c..5227489 100644 --- a/lib/e2b.ts +++ b/lib/e2b.ts @@ -30,7 +30,7 @@ export async function createSandbox({ files }: { files: z.infer !preInstalled.includes(dep));