|
1 | 1 | import{Request,Response}from'express'; |
2 | 2 | import{Card}from'./GraphCards'; |
3 | 3 | import{invalidUserSvg}from'./svgs'; |
4 | | -import{queryOption,colors,ParsedQs}from'../interfaces/interface'; |
| 4 | +import{ |
| 5 | +queryOption, |
| 6 | +colors, |
| 7 | +ParsedQs, |
| 8 | +userDetails, |
| 9 | +}from'../interfaces/interface'; |
5 | 10 | import{responseGraph}from'../types/types'; |
6 | 11 | import{fetchContributions}from'./fetching'; |
7 | 12 | import{selectColors}from'../styles/themes'; |
@@ -52,20 +57,22 @@ export const getGraph: responseGraph = async (req: Request, res: Response) =>{ |
52 | 57 | try{ |
53 | 58 | constoptions: queryOption=queryOptions(req.query); |
54 | 59 |
|
55 | | -constfetchCalendarData: number[]|string=awaitfetchContributions( |
| 60 | +constfetchCalendarData: userDetails|string=awaitfetchContributions( |
56 | 61 | `${options.username}` |
57 | 62 | ); |
58 | 63 |
|
59 | | -if(Array.isArray(fetchCalendarData)){ |
| 64 | +if(typeoffetchCalendarData==='object'){ |
60 | 65 | constgraph: Card=newCard( |
61 | 66 | 420, |
62 | 67 | 1200, |
63 | 68 | options.colors, |
64 | | -`${options.username}'s Contribution Graph`, |
| 69 | +`${fetchCalendarData.name}'s Contribution Graph`, |
65 | 70 | options.area |
66 | 71 | ); |
67 | 72 |
|
68 | | -constgetChart: string=awaitgraph.chart(fetchCalendarData); |
| 73 | +constgetChart: string=awaitgraph.chart( |
| 74 | +fetchCalendarData.contributions |
| 75 | +); |
69 | 76 |
|
70 | 77 | setHttpHeader(res,'public, max-age=1800'); |
71 | 78 | res.status(200).send(getChart); |
|
0 commit comments