New API endpoints:
- GET /api/projects/[id] - Get single project
- GET /api/sprints/[id] - Get single sprint
New CLI commands:
- project get <id> - Get specific project
- sprint get <id> - Get specific sprint
Project and Sprint CRUD now complete:
✅ list, get, create, update, delete
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { getServiceSupabase } from "@/lib/supabase/client";
|
|
import { getAuthenticatedUser } from "@/lib/server/auth";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
// GET - fetch single sprint by ID
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
try {
|
|
const user = await getAuthenticatedUser();
|
|
if (!user) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const { id } = await params;
|
|
|
|
const supabase = getServiceSupabase();
|
|
const { data, error } = await supabase
|
|
.from("sprints")
|
|
.select("*")
|
|
.eq("id", id)
|
|
.single();
|
|
|
|
if (error) {
|
|
if (error.code === "PGRST116") {
|
|
return NextResponse.json({ error: "Sprint not found" }, { status: 404 });
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
return NextResponse.json({ sprint: data });
|
|
} catch (error) {
|
|
console.error(">>> API GET /sprints/[id] error:", error);
|
|
return NextResponse.json({ error: "Failed to fetch sprint" }, { status: 500 });
|
|
}
|
|
}
|