@@ -16,6 +16,7 @@ import type {OSSIndexCategoryGroupDetails} from "~~/types/ossindex/category-grou
1616export default defineEventHandler ( async ( event ) : Promise < OSSIndexCategoryGroupDetails | Error > => {
1717 const query = getQuery ( event ) ;
1818 const categoryGroupSlug : string = ( query ?. categoryGroupSlug as string ) ;
19+ const sort : string = ( query ?. sort as string ) ;
1920
2021 try {
2122 const resDetails = await fetchFromTinybird < CategoryGroup [ ] > (
@@ -25,36 +26,41 @@ export default defineEventHandler(async (event): Promise<OSSIndexCategoryGroupDe
2526 }
2627 ) ;
2728
29+ const details : CategoryGroup | undefined = resDetails . data . at ( 0 ) ;
30+
31+ if ( ! details ) {
32+ throw createError ( { statusCode : 404 , statusMessage : 'Category group not found' } ) ;
33+ }
34+
2835 const res = await fetchFromTinybird < OSSIndexCategoryTinybird [ ] > (
2936 '/v0/pipes/categories_oss_index.json' ,
3037 {
3138 categoryGroupSlug,
39+ orderBy : sort ,
3240 }
3341 ) ;
3442
35- const details : CategoryGroup | undefined = resDetails . data . at ( 0 ) ;
36-
37- if ( ! details ) {
38- throw createError ( { statusCode : 404 , statusMessage : 'Category group not found' } ) ;
39- }
40-
4143 const categories = res . data . map ( ( item ) => ( {
4244 ...item ,
4345 topCollections : item . topCollections . map ( ( collection ) => {
44- const [ id , count , name ] = collection ;
46+ const [ id , count , name , softwareValue , avgScore ] = collection ;
4547 return {
4648 id : id as string ,
4749 count : count as number ,
4850 name : name as string ,
51+ softwareValue : softwareValue as number ,
52+ avgScore : avgScore as number ,
4953 } ;
5054 } ) ,
5155 topProjects : item . topProjects . map ( ( collection ) => {
52- const [ id , count , name , logo ] = collection ;
56+ const [ id , count , name , logo , softwareValue , avgScore ] = collection ;
5357 return {
5458 id : id as string ,
5559 count : count as number ,
5660 name : name as string ,
5761 logo : logo as string ,
62+ softwareValue : softwareValue as number ,
63+ avgScore : avgScore as number ,
5864 } ;
5965 } )
6066 } ) )
0 commit comments