Added basic validation for requests
This commit is contained in:
@@ -6,7 +6,7 @@ export async function GET(req: Request, { params } : { params: { id: string } })
|
||||
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 });
|
||||
}
|
||||
|
||||
let id = req.headers?.get('x-api-key')
|
||||
@@ -23,7 +23,7 @@ export async function GET(req: Request, { params } : { params: { id: string } })
|
||||
return NextResponse.json(tokens);
|
||||
} catch (error) {
|
||||
console.log("[TOKEN/GET]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function DELETE(req: Request, { params } : { params: { id: string }
|
||||
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 { id } = params
|
||||
@@ -45,6 +45,6 @@ export async function DELETE(req: Request, { params } : { params: { id: string }
|
||||
return NextResponse.json(token);
|
||||
} catch (error) {
|
||||
console.log("[TOKEN/DELETE]", 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