Added basic validation for requests
This commit is contained in:
@ -6,7 +6,7 @@ export async function POST(req: Request) {
|
||||
try {
|
||||
const user = await fetchUserWithImpersonation(req)
|
||||
if (!user) {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
return NextResponse.json({ message: 'Unauthorized.', error: null, value: null }, { status: 401 });
|
||||
}
|
||||
|
||||
const connection = await db.twitchConnection.deleteMany({
|
||||
@ -18,6 +18,6 @@ export async function POST(req: Request) {
|
||||
return NextResponse.json(connection);
|
||||
} catch (error) {
|
||||
console.log("[CONNECTION/TWITCH]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 })
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ export async function GET(req: Request) {
|
||||
try {
|
||||
const user = await fetchUserWithImpersonation(req)
|
||||
if (!user) {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
return NextResponse.json({ message: 'Unauthorized.', error: null, value: null }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(req.url)
|
||||
@ -27,6 +27,6 @@ export async function GET(req: Request) {
|
||||
return NextResponse.json(connection);
|
||||
} catch (error) {
|
||||
console.log("[CONNECTION/TWITCH]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user