@@ -22,47 +22,58 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
2222 } ;
2323 }
2424
25- const mostDownloadedResponse = await ssrFetch (
26- '/libraries' ,
27- {
28- order : 'downloads' ,
29- limit : LIMIT . toString ( ) ,
30- isMaintained : 'true' ,
31- hasNativeCode : 'true' ,
32- } ,
33- ctx
34- ) ;
35- const recentlyAddedResponse = await ssrFetch (
36- '/libraries' ,
37- { order : 'added' , limit : LIMIT . toString ( ) , isMaintained : 'true' } ,
38- ctx
39- ) ;
40- const recentlyUpdatedResponse = await ssrFetch (
41- '/libraries' ,
42- { order : 'updated' , limit : LIMIT . toString ( ) , isMaintained : 'true' } ,
43- ctx
44- ) ;
45- const popularResponse = await ssrFetch (
46- '/libraries' ,
47- {
48- order : 'popularity' ,
49- limit : LIMIT . toString ( ) ,
50- isMaintained : 'true' ,
51- isPopular : 'true' ,
52- wasRecentlyUpdated : 'true' ,
53- } ,
54- ctx
55- ) ;
25+ const [
26+ mostDownloadedResponse ,
27+ recentlyAddedResponse ,
28+ recentlyUpdatedResponse ,
29+ popularResponse ,
30+ statisticResponse ,
31+ ] = await Promise . all ( [
32+ ssrFetch (
33+ '/libraries' ,
34+ {
35+ order : 'downloads' ,
36+ limit : LIMIT . toString ( ) ,
37+ isMaintained : 'true' ,
38+ hasNativeCode : 'true' ,
39+ } ,
40+ ctx
41+ ) ,
42+ ssrFetch ( '/libraries' , { order : 'added' , limit : LIMIT . toString ( ) , isMaintained : 'true' } , ctx ) ,
43+ ssrFetch (
44+ '/libraries' ,
45+ { order : 'updated' , limit : LIMIT . toString ( ) , isMaintained : 'true' } ,
46+ ctx
47+ ) ,
48+ ssrFetch (
49+ '/libraries' ,
50+ {
51+ order : 'popularity' ,
52+ limit : LIMIT . toString ( ) ,
53+ isMaintained : 'true' ,
54+ isPopular : 'true' ,
55+ wasRecentlyUpdated : 'true' ,
56+ } ,
57+ ctx
58+ ) ,
59+ ssrFetch ( '/libraries/statistic' , { } , ctx ) ,
60+ ] ) ;
5661
57- const statisticResponse = await ssrFetch ( '/libraries/statistic' , { } , ctx ) ;
62+ const [ mostDownloaded , recentlyAdded , recentlyUpdated , popular , statistic ] = await Promise . all ( [
63+ mostDownloadedResponse . json ( ) ,
64+ recentlyAddedResponse . json ( ) ,
65+ recentlyUpdatedResponse . json ( ) ,
66+ popularResponse . json ( ) ,
67+ statisticResponse . json ( ) ,
68+ ] ) ;
5869
5970 return {
6071 props : {
61- mostDownloaded : await mostDownloadedResponse . json ( ) ,
62- recentlyAdded : await recentlyAddedResponse . json ( ) ,
63- recentlyUpdated : await recentlyUpdatedResponse . json ( ) ,
64- popular : await popularResponse . json ( ) ,
65- statistic : await statisticResponse . json ( ) ,
72+ mostDownloaded,
73+ recentlyAdded,
74+ recentlyUpdated,
75+ popular,
76+ statistic,
6677 } ,
6778 } ;
6879}
0 commit comments