2023-12-30 05:56:40 -05:00
|
|
|
import { db } from "@/lib/db"
|
2024-01-04 16:57:32 -05:00
|
|
|
import fetchUserWithImpersonation from "@/lib/fetch-user-impersonation";
|
2023-12-30 05:56:40 -05:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
|
|
|
export async function POST(req: Request) {
|
|
|
|
try {
|
2024-01-04 16:57:32 -05:00
|
|
|
const user = await fetchUserWithImpersonation(req)
|
2023-12-30 05:56:40 -05:00
|
|
|
if (!user) {
|
|
|
|
return new NextResponse("Unauthorized", { status: 401 });
|
|
|
|
}
|
|
|
|
|
|
|
|
const connection = await db.twitchConnection.deleteMany({
|
|
|
|
where: {
|
|
|
|
userId: user.id
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return NextResponse.json(connection);
|
|
|
|
} catch (error) {
|
|
|
|
console.log("[CONNECTION/TWITCH]", error);
|
|
|
|
return new NextResponse("Internal Error", { status: 500 });
|
|
|
|
}
|
|
|
|
}
|