File tree Expand file tree Collapse file tree 6 files changed +36
-9
lines changed
Expand file tree Collapse file tree 6 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ async function postHandler (request: NextRequest): Promise<any> {
1818 throw new Error ( 'Invalid payload' )
1919 }
2020 } catch ( error ) {
21- return NextResponse . json ( { error : 'Unexpected error' , status : 400 } )
21+ return NextResponse . json (
22+ { error } ,
23+ { status : 400 }
24+ )
2225 }
2326
2427 let response : Auth0 . JSONApiResponse < Auth0 . TokenSet > | undefined
Original file line number Diff line number Diff line change @@ -113,7 +113,10 @@ const postHandler = async (req: NextRequest): Promise<any> => {
113113
114114 if ( uuid == null || profileUrl == null || auth0Userid == null ) {
115115 // A bug in our code - shouldn't get here.
116- return NextResponse . json ( { status : 500 } )
116+ return NextResponse . json (
117+ { error : 'Internal Server Error' } ,
118+ { status : 500 }
119+ )
117120 }
118121
119122 // fetch data from mountain project here
Original file line number Diff line number Diff line change @@ -17,14 +17,20 @@ const getHanlder = async (req: NextRequest): Promise<any> => {
1717 try {
1818 const fullFilename = prepareFilenameFromRequest ( req )
1919 if ( fullFilename == null ) {
20- return NextResponse . json ( { status : 400 } )
20+ return NextResponse . json (
21+ { error : 'Bad Request - Missing filename parameter' } ,
22+ { status : 400 }
23+ )
2124 }
2225 const url = await getSignedUrlForUpload ( fullFilename )
2326
2427 return NextResponse . json ( { url, fullFilename : '/' + fullFilename } )
2528 } catch ( e ) {
2629 console . error ( 'Uploading to media server failed' , e )
27- return NextResponse . json ( { status : 500 } )
30+ return NextResponse . json (
31+ { error : 'Internal Server Error - Failed to generate signed URL' } ,
32+ { status : 500 }
33+ )
2834 }
2935}
3036
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ const getHandler = async (req: NextRequest): Promise<any> => {
1010 const accessToken = req . headers . get ( PREDEFINED_HEADERS . access_token )
1111
1212 if ( accessToken == null || uuid == null ) {
13- return NextResponse . json ( { status : 500 } )
13+ return NextResponse . json (
14+ { error : 'Internal Server Error' } ,
15+ { status : 500 }
16+ )
1417 }
1518
1619 try {
Original file line number Diff line number Diff line change @@ -11,13 +11,22 @@ const postHandler = async (req: NextRequest): Promise<any> => {
1111 try {
1212 const filename = getBucketPathFromRequest ( req )
1313 if ( filename == null ) {
14- return NextResponse . json ( { status : 400 } )
14+ return NextResponse . json (
15+ { error : 'Bad Request - Missing filename parameter' } ,
16+ { status : 400 }
17+ )
1518 }
1619 await deleteMediaFromBucket ( filename )
17- return NextResponse . json ( { status : 200 } )
20+ return NextResponse . json (
21+ { message : 'Media file deleted successfully' } ,
22+ { status : 200 }
23+ )
1824 } catch ( e ) {
1925 console . log ( 'Removing file from media server failed' , e )
20- return NextResponse . json ( { status : 500 } )
26+ return NextResponse . json (
27+ { error : 'Internal Server Error - Failed to delete media file' } ,
28+ { status : 500 }
29+ )
2130 }
2231}
2332
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ export const withUserAuth = (handler: Next13APIHandler): Next13APIHandler => {
1818 req . headers . set ( PREDEFINED_HEADERS . access_token , session . accessToken )
1919 return await handler ( req )
2020 } else {
21- return NextResponse . json ( { status : 401 } )
21+ return NextResponse . json (
22+ { error : 'Unauthorized - Authentication required' } ,
23+ { status : 401 }
24+ )
2225 }
2326 }
2427}
You can’t perform that action at this time.
0 commit comments