Added basic validation for requests

This commit is contained in:
Tom
2024-08-25 21:35:46 +00:00
parent 2d40d6fe09
commit 624b3fa63b
42 changed files with 608 additions and 492 deletions

View File

@@ -13,6 +13,8 @@ export async function POST(req: Request) {
if (!token_type)
return NextResponse.json({ error: null, message: 'No token type given for the authorization.', success: false }, { status: 400 })
if (token_type !== "bearer")
return NextResponse.json({ error: null, message: 'Invalid token type given for the authorization.', success: false }, { status: 400 })
if (!access_token)
return NextResponse.json({ error: null, message: 'No access token given for the authorization.', success: false }, { status: 400 })

View File

@@ -17,7 +17,7 @@ export async function GET(req: Request) {
}
})
return NextResponse.json({ error: null, message: "", success: true, data }, { status: 200 });
return NextResponse.json({ error: null, message: null, success: true, data }, { status: 200 });
} catch (error: any) {
return NextResponse.json({ error, message: "Failed to get default connection", success: false }, { status: 500 });
}
@@ -68,7 +68,7 @@ export async function PUT(req: Request) {
}
})
return NextResponse.json({ error: null, message: "", success: true, data }, { status: 200 });
return NextResponse.json({ error: null, message: null, success: true, data }, { status: 200 });
} catch (error: any) {
return NextResponse.json({ error, message: "Failed to update default connection", success: false }, { status: 500 });
}