Skip to content

Commit 3139711

Browse files
committed
moving countryUpperCase to helpers
1 parent c62a0e4 commit 3139711

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

app.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ const port = process.env.PORT || 3001;
55

66
const { getCountryTable } = require('./lib/byCountry');
77
const { getCompleteTable } = require('./lib/corona');
8+
const { countryUpperCase } = require('./lib/helpers');
89

9-
const countryUpperCase = (countryParams) => {
10-
if(countryParams.country.length > 2 ){
11-
const country = countryParams.country.toLowerCase().split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
12-
return { country };
13-
}
14-
return countryParams;
15-
};
1610

1711
app.get('/', (req, res) => {
1812
return getCompleteTable().then(result => {

lib/helpers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ e.getTotalStats = (countryData) => {
145145
return worldStats;
146146
};
147147

148+
e.countryUpperCase = (countryParams) => {
149+
if(countryParams.country.length > 2 ){
150+
const country = countryParams.country.toLowerCase().split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
151+
return { country };
152+
}
153+
return countryParams;
154+
};
155+
148156
e.footer = `
149157
150158
Source Code: https://github.com/sagarkarira/coronavirus-tracker-cli/

0 commit comments

Comments
 (0)