2023-10-14 17:05:01 -07:00
|
|
|
import { currentProfile } from "@/lib/current-profile";
|
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
import { db } from "@/lib/db";
|
|
|
|
|
|
|
|
export async function PATCH(req: Request, { params }: { params: { serverId: string }})
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const profile = await currentProfile();
|
|
|
|
const { name, imageUrl } = await req.json();
|
|
|
|
|
|
|
|
if (!profile)
|
|
|
|
{
|
|
|
|
return new NextResponse("Unauthorized", { status: 401 });
|
|
|
|
}
|
|
|
|
|
2023-10-14 17:09:23 -07:00
|
|
|
const server = await db.server.update
|
|
|
|
({
|
2023-10-14 17:05:01 -07:00
|
|
|
where:
|
|
|
|
{
|
|
|
|
id: params.serverId,
|
|
|
|
profileId: profile.id,
|
|
|
|
},
|
|
|
|
data:
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
imageUrl,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return NextResponse.json(server);
|
|
|
|
}
|
|
|
|
catch (error)
|
|
|
|
{
|
|
|
|
console.log("[SERVER_ID_PATCH]", error);
|
|
|
|
return new NextResponse("Internal Error", { status: 500});
|
|
|
|
}
|
|
|
|
}
|