@@ -4,6 +4,8 @@ const axios = require('axios'),
44 ora = require ( 'ora' ) ,
55 spinner = ora ( { text : 'Loading...' } ) ,
66 covid19 = require ( './lib/cli' ) ,
7+ covid19GFX = require ( './lib/cli/gfx' ) ,
8+ http = require ( 'http' ) ,
79 apiBaseURL = "https://corona.lmao.ninja" ,
810 argv = require ( 'yargs' )
911 . usage ( 'Usage: $0 <country> [options]' )
@@ -49,12 +51,46 @@ const getCountry = async (u, country) => {
4951 spinner . stop ( ) ;
5052 return console . log ( result ) ;
5153}
54+
55+
56+ const getCountryGFX = async ( u , country ) => {
57+ let result ;
58+ let resHead = { }
59+ const api = await axios . get ( `${ apiBaseURL } /countries/${ country } ` ) ,
60+ history = await axios . get ( `${ apiBaseURL } /v2/historical/${ api . data . country } ?lastdays=all` ) ,
61+ s = api . data ,
62+ h = history . data ,
63+ chartType = 'cases' ;
64+
65+
66+ var http = require ( 'http' ) ;
67+ http . createServer ( function ( req , res ) {
68+ resHead = res
69+ return covid19GFX . historyCountryTracker (
70+ req , res ,
71+ s . country , s . cases , s . todayCases ,
72+ s . deaths , s . todayDeaths , s . recovered ,
73+ s . active , s . critical , s . casesPerOneMillion ,
74+ s . updated , h , chartType , s . countryInfo )
75+ } ) . listen ( 1000 ) ;
76+
77+ result = await axios . get ( 'http://localhost:1000' )
78+ clear ( )
79+ spinner . stop ( ) ;
80+ console . log ( result . data )
81+ return 'dfdfd'
82+
83+
84+
85+
86+ }
87+
5288
5389( async ( ) => {
5490 clear ( ) ;
55- country = argv . _ [ 0 ] ;
5691 spinner . start ( ) ;
92+ country = argv . _ [ 0 ] ;
5793 const all = await axios . get ( `${ apiBaseURL } /all` ) ;
58- ! country && getGlobal ( all . data ) ;
59- country && getCountry ( all . data , country ) ;
94+ getCountryGFX ( all . data , country ) ;
95+
6096} ) ( )
0 commit comments