hermes-web/app/api/settings/connections/twitch/delete/route.ts

23 lines
670 B
TypeScript
Raw Normal View History

2023-12-30 05:56:40 -05:00
import { db } from "@/lib/db"
import fetchUserUsingAPI from "@/lib/validate-api";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const user = await fetchUserUsingAPI(req)
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 });
}
}