Skip to content

Commit 3abc974

Browse files
author
Waren Gonzaga
committed
Merge branch 'dev'
2 parents 802dfba + b882bc5 commit 3abc974

21 files changed

+2380
-288
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
.now
2+
.now
3+
.DS_Store

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# COVID-19 Tracker CLI [![Developed by Waren Gonzaga](https://img.shields.io/badge/Developed%20by-Waren%20Gonzaga-blue.svg?longCache=true&style=for-the-badge)](https://facebook.com/warengonzagaofficial)
22

3-
[![Github Release](https://img.shields.io/github/release/warengonzaga/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli/releases)
4-
[![Github Star](https://img.shields.io/github/stars/warengonzaga/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli)
5-
[![Github Fork](https://img.shields.io/github/forks/warengonzaga/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli)
6-
[![License](https://img.shields.io/github/license/warengonzaga/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli)
7-
[![Powered By](https://img.shields.io/badge/Powered%20By-NodeJS-green.svg?style=for-the-badge)](https://nodejs.org)
3+
[![Github Release](https://img.shields.io/github/release/tracker-cli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli/releases) [![Github Star](https://img.shields.io/github/stars/tracker-cli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli) [![Github Fork](https://img.shields.io/github/forks/tracker-cli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli) [![License](https://img.shields.io/github/license/tracker-cli/covid19-tracker-cli.svg?style=for-the-badge)](https://github.com/warengonzaga/covid19-tracker-cli) [![Powered By](https://img.shields.io/badge/Powered%20By-NodeJS-green.svg?style=for-the-badge)](https://nodejs.org)
84

95
![Github Banner](./lib/img/covid19-tracker-cli-github-banner.jpg)
106

11-
**COVID-19 Tracker CLI** is an open-source NodeJS application for command line interface to track COVID-19 cases around the world. An optimized NodeJS application and a simple tracker with real-time updates from reliable data source. [Visit Wiki](https://github.com/warengonzaga/covid19-tracker-cli/wiki)
7+
**COVID-19 Tracker CLI** is an open-source NodeJS application for command line interface to track COVID-19 cases around the world. An optimized NodeJS application and a simple tracker with real-time updates from reliable data source. [Visit Wiki](https://github.com/tracker-cli/covid19-tracker-cli/wiki)
128

139
## Domain Names
1410

@@ -88,6 +84,8 @@ wget -i https://covid19.trackercli.com && cat index.html
8884
http http://covid19.trackercli.com
8985
```
9086

87+
![CURL](./lib/img/demo-global.gif)
88+
9189
### Country Tracking
9290

9391
To track COVID-19 cases on CLI by country, all you need to do is to append the URL with the country name or country [ISO 3166-1](https://warengonza.ga/iso-3166-1-codes) code.
@@ -106,6 +104,8 @@ curl -L covid19.trackercli.com/philippines
106104
curl -L covid19.trackercli.com/ph
107105
```
108106

107+
![CURL](./lib/img/demo-country.gif)
108+
109109
#### Global Tracking with History Chart
110110

111111
```bash
@@ -118,6 +118,8 @@ curl -L covid19.trackercli.com/history
118118
curl -L covid19.trackercli.com/history/all
119119
```
120120

121+
![CURL](./lib/img/demo-history-global.gif)
122+
121123
#### Country Tracking with History Chart
122124

123125
```bash
@@ -135,6 +137,8 @@ curl -L covid19.trackercli.com/history/ph/cases
135137
curl -L covid19.trackercli.com/history/ph/deaths
136138
```
137139

140+
![CURL](./lib/img/demo-history-country.gif)
141+
138142
## Advance Usage
139143

140144
### Check Update Automagically

app.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ const express = require('express'),
44
util = require('./bin/util'),
55
axios = require('axios'),
66
covid19 = require('./lib/cli'),
7+
covid19GFX = require('./lib/cli/gfx'),
78
pkg = require('./package.json'), // package.json info
8-
apiBaseURL = "https://corona.lmao.ninja", // NovelCOVID API
9+
apiBaseURL = "https://corona.lmao.ninja/v2", // NovelCOVID API
910
port = process.env.port || 7070; // set port
1011

1112
// global route for covid19 tracker
@@ -28,7 +29,7 @@ app.get(['/history/all/:chartType(cases|deaths)?', '/history/'], async (req, res
2829
const userAgent = req.headers['user-agent'],
2930
api = await axios.get(`${apiBaseURL}/all`),
3031
chartType = req.params.chartType || 'cases',
31-
history = await axios.get(`${apiBaseURL}/v2/historical/all?lastdays=all`),
32+
history = await axios.get(`${apiBaseURL}/historical/all?lastdays=all`),
3233
h = history.data;
3334
data = api.data;
3435

@@ -110,7 +111,7 @@ app.get('/history/:country/:chartType(cases|deaths)?', async (req, res, next) =>
110111
countryData = req.params.country,
111112
chartType = req.params.chartType || 'cases',
112113
summary = await axios.get(`${apiBaseURL}/countries/${countryData}`),
113-
history = await axios.get(`${apiBaseURL}/v2/historical/${summary.data.country}?lastdays=all`),
114+
history = await axios.get(`${apiBaseURL}/historical/${summary.data.country}?lastdays=all`),
114115
s = summary.data,
115116
h = history.data;
116117

@@ -128,6 +129,30 @@ app.get('/history/:country/:chartType(cases|deaths)?', async (req, res, next) =>
128129
return next();
129130
});
130131

132+
133+
// historical chart by country
134+
app.get('/history/charts/:country', async (req, res, next) => {
135+
const userAgent = req.headers['user-agent'],
136+
countryData = req.params.country,
137+
chartType = req.params.chartType || 'cases',
138+
summary = await axios.get(`${apiBaseURL}/countries/${countryData}`),
139+
history = await axios.get(`${apiBaseURL}/v2/historical/${summary.data.country}?lastdays=all`),
140+
s = summary.data,
141+
h = history.data;
142+
143+
if (util.isCommandline(userAgent)) {
144+
covid19GFX.historyCountryTracker(
145+
req, res,
146+
s.country, s.cases, s.todayCases,
147+
s.deaths, s.todayDeaths, s.recovered,
148+
s.active, s.critical, s.casesPerOneMillion,
149+
s.updated, h, chartType, s.countryInfo
150+
)
151+
return null;
152+
}
153+
return next();
154+
});
155+
131156
app.get('*', (req, res) => res.send(`
132157
Welcome to COVID-19 Tracker CLI v${pkg.version} by Waren Gonzaga\n
133158
Please visit: https://warengonza.ga/covid19-tracker-cli
File renamed without changes.

bin/util/helper.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const ansi = require("ansi-styles");
2+
3+
const color = {
4+
tblclr: (border) => ansi.cyan.open + border + ansi.cyan.close,
5+
white: (txt) => ansi.white.open + txt + ansi.white.close,
6+
black: (txt) => ansi.black.open + txt + ansi.black.close,
7+
green: (txt) => ansi.green.open + txt + ansi.green.close,
8+
cyan: (txt) => ansi.cyan.open + txt + ansi.cyan.close,
9+
magenta: (txt) => ansi.magenta.open + txt + ansi.magenta.close,
10+
yellow: (txt) => ansi.yellow.open + txt + ansi.yellow.close,
11+
red: (txt) => ansi.red.open + txt + ansi.red.close,
12+
cyanBright: (txt) => ansi.cyanBright.open + txt + ansi.cyanBright.close,
13+
magentaBright: (txt) =>
14+
ansi.magentaBright.open + txt + ansi.magentaBright.close,
15+
redBright: (txt) => ansi.redBright.open + txt + ansi.redBright.close,
16+
greenBright: (txt) => ansi.greenBright.open + txt + ansi.greenBright.close,
17+
cyanBG: (txt) => ansi.bgCyan.open + txt + ansi.bgCyan.close,
18+
};
19+
exports.color = color;
20+
21+
exports.txt = {
22+
line: "-".repeat(60),
23+
tab: " ",
24+
space: " ",
25+
br: "\n",
26+
};
27+
28+
exports.formatNumber = (value) =>
29+
value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
30+
exports.ucfirst = (string) => string.charAt(0).toUpperCase() + string.slice(1);
31+
32+
exports.table = {
33+
borders: {
34+
top: color.tblclr("═"),
35+
"top-mid": color.tblclr("╤"),
36+
"top-left": color.tblclr("╔"),
37+
"top-right": color.tblclr("╗"),
38+
bottom: color.tblclr("═"),
39+
"bottom-mid": color.tblclr("╧"),
40+
"bottom-left": color.tblclr("╚"),
41+
"bottom-right": color.tblclr("╝"),
42+
left: color.tblclr("║"),
43+
"left-mid": color.tblclr("╟"),
44+
mid: color.tblclr("─"),
45+
"mid-mid": color.tblclr("┼"),
46+
right: color.tblclr("║"),
47+
"right-mid": color.tblclr("╢"),
48+
middle: color.tblclr("│"),
49+
},
50+
col5: (txt) => {
51+
return { colSpan: 5, content: txt };
52+
},
53+
};

0 commit comments

Comments
 (0)