Add debug endpoint
This commit is contained in:
parent
bacca13be5
commit
06bd8e188e
34
src/app/api/debug/route.ts
Normal file
34
src/app/api/debug/route.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { getServiceSupabase } from "@/lib/supabase/client";
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
try {
|
||||||
|
const supabase = getServiceSupabase();
|
||||||
|
|
||||||
|
// Test database connection
|
||||||
|
const { data: tasks, error } = await supabase
|
||||||
|
.from("tasks")
|
||||||
|
.select("count")
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return NextResponse.json({ error: error.message, code: error.code }, { status: 500 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check env vars
|
||||||
|
const envCheck = {
|
||||||
|
hasUrl: !!process.env.SUPABASE_URL || !!process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||||
|
hasAnonKey: !!process.env.SUPABASE_ANON_KEY || !!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||||
|
hasServiceKey: !!process.env.SUPABASE_SERVICE_ROLE_KEY || !!process.env.SUPABASE_SECRET_KEY,
|
||||||
|
};
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
taskCount: tasks?.[0]?.count || 0,
|
||||||
|
env: envCheck
|
||||||
|
});
|
||||||
|
} catch (err: unknown) {
|
||||||
|
const message = err instanceof Error ? err.message : "Unknown error";
|
||||||
|
return NextResponse.json({ error: message }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,8 +27,9 @@ export async function POST(req: NextRequest) {
|
|||||||
dueDate: parsed.dueDate,
|
dueDate: parsed.dueDate,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: unknown) {
|
||||||
console.error("Error parsing task:", err);
|
console.error("Error parsing task:", err);
|
||||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
const message = err instanceof Error ? err.message : "Unknown error";
|
||||||
|
return NextResponse.json({ error: message }, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,13 @@ export function parseTaskInput(input: string): ParsedTask {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addTaskToGantt(input: string): Promise<{ success: boolean; task?: any; error?: string }> {
|
interface TaskResult {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addTaskToGantt(input: string): Promise<{ success: boolean; task?: TaskResult; error?: string }> {
|
||||||
try {
|
try {
|
||||||
const parsed = parseTaskInput(input);
|
const parsed = parseTaskInput(input);
|
||||||
|
|
||||||
@ -122,8 +128,9 @@ export async function addTaskToGantt(input: string): Promise<{ success: boolean;
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { success: true, task };
|
return { success: true, task };
|
||||||
} catch (err: any) {
|
} catch (err: unknown) {
|
||||||
console.error("Failed to add task:", err);
|
console.error("Failed to add task:", err);
|
||||||
return { success: false, error: err.message };
|
const message = err instanceof Error ? err.message : "Unknown error";
|
||||||
|
return { success: false, error: message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user