Files
open-lovable/app/api/sandbox-status/route.ts
T
Developers Digest 1629e12079 initial
2025-08-08 09:04:33 -04:00

54 lines
1.5 KiB
TypeScript

import { NextResponse } from 'next/server';
declare global {
var activeSandbox: any;
var sandboxData: any;
var existingFiles: Set<string>;
}
export async function GET() {
try {
// Check if sandbox exists
const sandboxExists = !!global.activeSandbox;
let sandboxHealthy = false;
let sandboxInfo = null;
if (sandboxExists && global.activeSandbox) {
try {
// Since Python isn't available in the Vite template, just check if sandbox exists
// The sandbox object existing is enough to confirm it's healthy
sandboxHealthy = true;
sandboxInfo = {
sandboxId: global.sandboxData?.sandboxId,
url: global.sandboxData?.url,
filesTracked: global.existingFiles ? Array.from(global.existingFiles) : [],
lastHealthCheck: new Date().toISOString()
};
} catch (error) {
console.error('[sandbox-status] Health check failed:', error);
sandboxHealthy = false;
}
}
return NextResponse.json({
success: true,
active: sandboxExists,
healthy: sandboxHealthy,
sandboxData: sandboxInfo,
message: sandboxHealthy
? 'Sandbox is active and healthy'
: sandboxExists
? 'Sandbox exists but is not responding'
: 'No active sandbox'
});
} catch (error) {
console.error('[sandbox-status] Error:', error);
return NextResponse.json({
success: false,
active: false,
error: (error as Error).message
}, { status: 500 });
}
}