@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
33import { v4 } from "uuid" ;
44
55type BulkVotesResponse = {
6- ok : boolean ;
6+ success : boolean ;
77 votes : Record < string , { vote_count : number ; user_voted : boolean } > ;
88} ;
99
@@ -18,31 +18,31 @@ export default async function getBulkRoadmapItemVotes(
1818 // Validate HTTP method
1919 if ( req . method !== "POST" ) {
2020 res . setHeader ( "Allow" , "POST" ) ;
21- return res . status ( 405 ) . json ( { ok : false , votes : { } } ) ;
21+ return res . status ( 405 ) . json ( { success : false , votes : { } } ) ;
2222 }
2323
2424 const { item_ids } = req . body ;
2525 let { cp_pa_vid : visitor_id } = req . cookies ;
2626
2727 // Input validation
2828 if ( ! item_ids || ! Array . isArray ( item_ids ) ) {
29- return res . status ( 400 ) . json ( { ok : false , votes : { } } ) ;
29+ return res . status ( 400 ) . json ( { success : false , votes : { } } ) ;
3030 }
3131
3232 // Prevent abuse with max array length
3333 if ( item_ids . length > 100 ) {
34- return res . status ( 400 ) . json ( { ok : false , votes : { } } ) ;
34+ return res . status ( 400 ) . json ( { success : false , votes : { } } ) ;
3535 }
3636
3737 // Validate all item_ids are valid UUIDs
3838 if ( ! item_ids . every ( ( id ) => typeof id === "string" && UUID_REGEX . test ( id ) ) ) {
39- return res . status ( 400 ) . json ( { ok : false , votes : { } } ) ;
39+ return res . status ( 400 ) . json ( { success : false , votes : { } } ) ;
4040 }
4141
4242 // De-duplicate to keep queries lean
4343 const distinctItemIds : string [ ] = Array . from ( new Set ( item_ids ) ) ;
4444 if ( distinctItemIds . length === 0 ) {
45- return res . status ( 200 ) . json ( { ok : true , votes : { } } ) ;
45+ return res . status ( 200 ) . json ( { success : true , votes : { } } ) ;
4646 }
4747
4848 if ( ! visitor_id ) {
@@ -76,7 +76,7 @@ export default async function getBulkRoadmapItemVotes(
7676 "getBulkRoadmapItemVotes [User Error]" ,
7777 userVoteResult . error
7878 ) ;
79- return res . status ( 500 ) . json ( { ok : false , votes : { } } ) ;
79+ return res . status ( 500 ) . json ( { success : false , votes : { } } ) ;
8080 }
8181
8282 // Check for any errors in vote count queries
@@ -87,7 +87,7 @@ export default async function getBulkRoadmapItemVotes(
8787 distinctItemIds [ i ] ,
8888 voteCountResults [ i ] . error
8989 ) ;
90- return res . status ( 500 ) . json ( { ok : false , votes : { } } ) ;
90+ return res . status ( 500 ) . json ( { success : false , votes : { } } ) ;
9191 }
9292 }
9393
@@ -111,11 +111,11 @@ export default async function getBulkRoadmapItemVotes(
111111 } ) ;
112112
113113 res . status ( 200 ) . json ( {
114- ok : true ,
114+ success : true ,
115115 votes,
116116 } ) ;
117117 } catch ( e : Error | any ) {
118118 console . log ( "getBulkRoadmapItemVotes [Error]" , e ) ;
119- res . status ( 500 ) . json ( { ok : false , votes : { } } ) ;
119+ res . status ( 500 ) . json ( { success : false , votes : { } } ) ;
120120 }
121121}
0 commit comments