Some checks failed
Deploy to Cloudflare Workers / deploy (push) Has been cancelled
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { createClient } from "@/lib/supabase/server";
|
|
import { requireUser } from "@/lib/api/auth";
|
|
import { apiError, apiSuccess, parseJson } from "@/lib/api/errors";
|
|
import * as teams from "@/lib/services/teams";
|
|
|
|
export async function PATCH(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ teamId: string }> }
|
|
) {
|
|
try {
|
|
const { teamId } = await params;
|
|
const supabase = await createClient();
|
|
await requireUser(supabase);
|
|
const body = await parseJson<{
|
|
home_stadium_name?: string;
|
|
logo_path?: string;
|
|
nickname?: string;
|
|
icon?: string;
|
|
}>(request);
|
|
const data = await teams.updateTeam(supabase, teamId, body);
|
|
return apiSuccess(data);
|
|
} catch (e) {
|
|
return apiError(e);
|
|
}
|
|
}
|
|
|
|
export async function DELETE(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ teamId: string }> }
|
|
) {
|
|
try {
|
|
const { teamId } = await params;
|
|
const supabase = await createClient();
|
|
await requireUser(supabase);
|
|
await teams.deleteTeam(supabase, teamId);
|
|
return apiSuccess({ deleted: true });
|
|
} catch (e) {
|
|
return apiError(e);
|
|
}
|
|
}
|