@@ -9,7 +9,13 @@ const router = Router()
99const getProposals = async ( req : Request , res : Response ) => {
1010 const size = req . query . size ? + req . query . size : 10
1111 const page = req . query . page ? + req . query . page : 1
12- const type = req . query . type ? ( req . query . type as ProposalTypes ) : undefined
12+ const type = req . query . type
13+ ? Array . isArray ( req . query . type )
14+ ? ( req . query . type as ProposalTypes [ ] )
15+ : typeof req . query . type === 'string'
16+ ? req . query . type . split ( ',' ) . map ( ( type ) => type as ProposalTypes )
17+ : undefined
18+ : undefined
1319 const sort = req . query . sort ? ( req . query . sort as SortTypes ) : undefined
1420 const includeVoteCount = 'true' == ( req . query . vote_count as string )
1521 let proposal = req . query . proposal as string
@@ -21,7 +27,7 @@ const getProposals = async (req: Request, res: Response) => {
2127 proposal = proposal . includes ( '#' ) ? proposal . split ( '#' ) [ 0 ] : proposal
2228 }
2329 const { items, totalCount } = await fetchProposals ( page , size , proposal , type , sort , includeVoteCount )
24- return res . status ( 200 ) . json ( { totalCount : Math . round ( totalCount / size ) , page, size, items } )
30+ return res . status ( 200 ) . json ( { totalCount : totalCount , page, size, items } )
2531}
2632
2733const getProposalVoteCount = async ( req : Request , res : Response ) => {
0 commit comments