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

23 lines
789 B
TypeScript

import { db } from "@/lib/db"
import fetchUserWithImpersonation from "@/lib/fetch-user-impersonation";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const user = await fetchUserWithImpersonation(req)
if (!user) {
return NextResponse.json({ message: 'Unauthorized.', error: null, value: null }, { status: 401 });
}
const connection = await db.twitchConnection.deleteMany({
where: {
userId: user.id
}
});
return NextResponse.json(connection);
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 })
}
}