1
1
import { NextRequest , NextResponse } from 'next/server'
2
2
import prisma from '@/lib/db'
3
- import { withLogging } from '@/lib/logger'
3
+ import { withLogging , logger } from '@/lib/logger'
4
4
5
5
export const POST = withLogging ( async ( request : NextRequest ) => {
6
6
try {
7
7
const locationData = await request . json ( )
8
- console . log ( 'locationData' , locationData )
8
+ logger . info ( 'locationData' , locationData )
9
9
// Validate required fields
10
10
if ( ! locationData ) {
11
- console . log ( 'Invalid location data:' , locationData )
11
+ logger . info ( 'Invalid location data:' , locationData )
12
12
return NextResponse . json ( { error : 'Invalid location data.' } , { status : 400 } )
13
13
}
14
14
@@ -28,7 +28,7 @@ export const POST = withLogging(async (request: NextRequest) => {
28
28
} )
29
29
30
30
if ( ! subscription ) {
31
- console . log ( 'Subscription not found for subscriptionId:' , locationData . subscriptionId )
31
+ logger . info ( 'Subscription not found for subscriptionId:' , locationData . subscriptionId )
32
32
return NextResponse . json ( { error : 'Subscription not found.' } , { status : 404 } )
33
33
}
34
34
@@ -67,14 +67,14 @@ export const POST = withLogging(async (request: NextRequest) => {
67
67
} ,
68
68
} )
69
69
70
- console . log ( 'Location added:' , newLocation )
70
+ logger . info ( 'Location added:' , newLocation )
71
71
return NextResponse . json (
72
72
{ message : 'Location added successfully.' , location : newLocation } ,
73
73
{ status : 201 }
74
74
)
75
75
} catch ( error ) {
76
- console . log ( 'Error saving location:' , error ) //error()
77
- console . log ( error . stack )
76
+ logger . info ( 'Error saving location:' , error ) //error()
77
+ logger . info ( error . stack )
78
78
return NextResponse . json ( { error : 'Failed to save location.' } , { status : 500 } )
79
79
} finally {
80
80
await prisma . $disconnect ( )
0 commit comments