1
- import { db } from " @/db/db" ;
2
- import { NextRequest , NextResponse } from " next/server" ;
1
+ import { db } from ' @/db/db' ;
2
+ import { NextRequest , NextResponse } from ' next/server' ;
3
3
4
4
type Params = {
5
5
params : {
6
- repositoryId : string
7
- issueNumber : string
8
- }
9
- }
6
+ repositoryId : string ;
7
+ issueNumber : string ;
8
+ } ;
9
+ } ;
10
10
11
11
export async function GET ( req : NextRequest , { params } : Params ) {
12
12
// Access the issueNumber from the request parameters: api/bounties/[issueNumber]
13
13
const { issueNumber, repositoryId } = params ;
14
14
15
- if ( ! issueNumber || isNaN ( parseInt ( issueNumber ) ) ) {
16
- return NextResponse . json (
17
- { message : "Invalid data" } ,
18
- { status : 400 }
19
- ) ;
15
+ if ( ! issueNumber || isNaN ( parseInt ( issueNumber ) ) ) {
16
+ return NextResponse . json ( { message : 'Invalid data' } , { status : 400 } ) ;
20
17
}
21
18
22
19
try {
23
20
const bounty = await db . bounty . findUnique ( {
24
21
where : {
25
22
issueNumber_repositoryId : {
26
23
issueNumber : parseInt ( issueNumber ) ,
27
- repositoryId : parseInt ( repositoryId )
28
- }
24
+ repositoryId : parseInt ( repositoryId ) ,
25
+ } ,
29
26
} ,
30
27
select : {
31
28
amount : true ,
32
- }
33
- } )
34
-
35
- if ( ! bounty ) {
29
+ } ,
30
+ } ) ;
31
+
32
+ if ( ! bounty ) {
36
33
return NextResponse . json ( {
37
34
isBounty : false ,
38
- bounty : null
35
+ bounty : null ,
39
36
} ) ;
40
37
}
41
-
42
- console . log ( " Bounty Comment: " , bounty ) ;
38
+
39
+ console . log ( ' Bounty Comment: ' , bounty ) ;
43
40
return NextResponse . json ( {
44
41
isBounty : true ,
45
- bounty : bounty . amount
42
+ bounty : bounty . amount ,
46
43
} ) ;
47
44
} catch ( error ) {
48
- console . error ( " Error checking bounty comment: " , error ) ;
45
+ console . error ( ' Error checking bounty comment: ' , error ) ;
49
46
return NextResponse . json (
50
- { message : "Error checking bounty comment" } ,
51
- { status : 500 } ) ;
47
+ { message : 'Error checking bounty comment' } ,
48
+ { status : 500 }
49
+ ) ;
52
50
}
53
- }
51
+ }
0 commit comments