Skip to content

Commit 05b670a

Browse files
committed
fix eslint issue
1 parent 11583cb commit 05b670a

File tree

3 files changed

+14
-200
lines changed

3 files changed

+14
-200
lines changed

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const { lookupCountry, htmlTemplate, footer } = require('./lib/helpers');
1313
const { getLiveUpdates } = require('./lib/reddit.js');
1414
const { getWorldoMetersTable } = require('./lib/worldoMeters.js');
1515
const { getUsaStats } = require('./lib/country/us.js');
16-
const { helpContent, countryNotFound } = require('./lib/constants');
16+
const { helpContent, countryNotFound, stateCountryNotFound } = require('./lib/constants');
1717

1818
const app = express();
1919
const port = process.env.PORT || 3001;
@@ -136,7 +136,7 @@ app.get('/states/:country', (req, res) => {
136136
const lookupObj = lookupCountry(country);
137137

138138
if (!lookupObj) {
139-
return res.status(404).send(countryNotFound(isCurl));
139+
return res.status(404).send(stateCountryNotFound(isCurl));
140140
}
141141
if (lookupObj.iso2 === 'US') {
142142
return getUsaStats({ isCurl, minimal, top, format})

lib/api.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
const NodeCache = require('node-cache');
99
const axios = require('axios');
10-
const { countryNameMap } = require('./constants');
1110

1211
const myCache = new NodeCache({ stdTTL: 100, checkperiod: 600 });
1312

lib/constants.js

Lines changed: 12 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,201 +1,4 @@
11
const { htmlTemplate, footer } = require('./helpers');
2-
exports.countryNameMap = {
3-
China: 'CN',
4-
UK: 'GB',
5-
Martinique: 'MQ',
6-
Liechtenstein: 'LI',
7-
'Réunion': 'RE',
8-
Ukraine: 'UA',
9-
Honduras: 'HN',
10-
Afghanistan: 'AF',
11-
Bangladesh: 'BD',
12-
Macao: 'MO',
13-
Bolivia: 'BO',
14-
Cuba: 'CU',
15-
Netherlands: 'NL',
16-
Jamaica: 'JM',
17-
'French Guiana': 'GF',
18-
DRC: 'CD',
19-
Cameroon: 'CM',
20-
Maldives: 'MV',
21-
Montenegro: 'ME',
22-
Paraguay: 'PY',
23-
Nigeria: 'NG',
24-
Guam: 'GU',
25-
'French Polynesia': 'PF',
26-
Austria: 'AT',
27-
Ghana: 'GH',
28-
Rwanda: 'RW',
29-
Monaco: 'MC',
30-
Gibraltar: 'GI',
31-
Guatemala: 'GT',
32-
'Ivory Coast': 'CI',
33-
Ethiopia: 'ET',
34-
Togo: 'TG',
35-
'Trinidad and Tobago': 'TT',
36-
Kenya: 'KE',
37-
Belgium: 'BE',
38-
Mauritius: 'MU',
39-
'Equatorial Guinea': 'GQ',
40-
Kyrgyzstan: 'KG',
41-
Mongolia: 'MN',
42-
'Puerto Rico': 'PR',
43-
Seychelles: 'SC',
44-
Tanzania: 'TZ',
45-
Guyana: 'GY',
46-
Aruba: 'AW',
47-
Barbados: 'BB',
48-
Norway: 'NO',
49-
Mayotte: 'YT',
50-
'Cayman Islands': 'KY',
51-
'Curaçao': 'CW',
52-
Bahamas: 'BS',
53-
Congo: 'CD',
54-
Gabon: 'GA',
55-
Namibia: 'NA',
56-
'St. Barth': 'BL',
57-
'Saint Martin': 'MF',
58-
'U.S. Virgin Islands': 'VI',
59-
Sweden: 'SE',
60-
Sudan: 'SD',
61-
Benin: 'BJ',
62-
Bermuda: 'BM',
63-
Bhutan: 'BT',
64-
CAR: 'CF',
65-
Greenland: 'GL',
66-
Haiti: 'HT',
67-
Liberia: 'LR',
68-
Mauritania: 'MR',
69-
'New Caledonia': 'NC',
70-
Denmark: 'DK',
71-
'Saint Lucia': 'LC',
72-
Zambia: 'ZM',
73-
Nepal: 'NP',
74-
Angola: 'AO',
75-
'Antigua and Barbuda': 'AG',
76-
'Cabo Verde': 'CV',
77-
Chad: 'TD',
78-
Djibouti: 'DJ',
79-
'El Salvador': 'SV',
80-
Fiji: 'FJ',
81-
Japan: 'JP',
82-
Gambia: 'GM',
83-
Guinea: 'GN',
84-
'Vatican City': 'VA',
85-
'Isle of Man': 'IM',
86-
Montserrat: 'MS',
87-
Nicaragua: 'NI',
88-
Niger: 'NE',
89-
'St. Vincent Grenadines': 'VC',
90-
'Sint Maarten': 'SX',
91-
Somalia: 'SO',
92-
Malaysia: 'MY',
93-
Suriname: 'SR',
94-
Eswatini: 'SZ',
95-
Australia: 'AU',
96-
Italy: 'IT',
97-
Canada: 'CA',
98-
Portugal: 'PT',
99-
Czechia: 'CZ',
100-
Israel: 'IL',
101-
Brazil: 'BR',
102-
Luxembourg: 'LU',
103-
Ireland: 'IE',
104-
Greece: 'GR',
105-
Qatar: 'QA',
106-
Pakistan: 'PK',
107-
Iran: 'IR',
108-
Finland: 'FI',
109-
Poland: 'PL',
110-
Turkey: 'TR',
111-
Singapore: 'SG',
112-
Chile: 'CL',
113-
Iceland: 'IS',
114-
Thailand: 'TH',
115-
Slovenia: 'SI',
116-
Indonesia: 'ID',
117-
Bahrain: 'BH',
118-
Spain: 'ES',
119-
Romania: 'RO',
120-
'Saudi Arabia': 'SA',
121-
Estonia: 'EE',
122-
Ecuador: 'EC',
123-
Egypt: 'EG',
124-
Peru: 'PE',
125-
Philippines: 'PH',
126-
'Hong Kong': 'HK',
127-
India: 'IN',
128-
Russia: 'RU',
129-
Germany: 'DE',
130-
Iraq: 'IQ',
131-
Mexico: 'MX',
132-
Lebanon: 'LB',
133-
'South Africa': 'ZA',
134-
Kuwait: 'KW',
135-
'San Marino': 'SM',
136-
UAE: 'AE',
137-
Panama: 'PA',
138-
Armenia: 'AM',
139-
Taiwan: 'TW',
140-
USA: 'US',
141-
Argentina: 'AR',
142-
Colombia: 'CO',
143-
Slovakia: 'SK',
144-
Serbia: 'RS',
145-
Croatia: 'HR',
146-
Bulgaria: 'BG',
147-
Uruguay: 'UY',
148-
Algeria: 'DZ',
149-
'Costa Rica': 'CR',
150-
Latvia: 'LV',
151-
France: 'FR',
152-
Hungary: 'HU',
153-
Vietnam: 'VN',
154-
'Faeroe Islands': 'FO',
155-
Andorra: 'AD',
156-
Brunei: 'BN',
157-
Belarus: 'BY',
158-
Jordan: 'JO',
159-
Cyprus: 'CY',
160-
'Sri Lanka': 'LK',
161-
Albania: 'AL',
162-
'S. Korea': 'KR',
163-
'Bosnia and Herzegovina': 'BA',
164-
Morocco: 'MA',
165-
Malta: 'MT',
166-
'North Macedonia': 'MK',
167-
Moldova: 'MD',
168-
Kazakhstan: 'KZ',
169-
Lithuania: 'LT',
170-
Oman: 'OM',
171-
Cambodia: 'KH',
172-
Palestine: 'PS',
173-
Switzerland: 'CH',
174-
Guadeloupe: 'GP',
175-
Azerbaijan: 'AZ',
176-
Georgia: 'GE',
177-
Venezuela: 'VE',
178-
Tunisia: 'TN',
179-
'New Zealand': 'NZ',
180-
Senegal: 'SN',
181-
'Dominican Republic': 'DO',
182-
'Burkina Faso': 'BF',
183-
Uzbekistan: 'UZ',
184-
'Madagascar': 'MG',
185-
'Uganda': 'UG',
186-
'Zimbabwe': 'ZW',
187-
'Dominica': 'DM',
188-
'Laos': 'LA',
189-
'Myanmar': 'MM',
190-
'Belize': 'BZ',
191-
'Eritrea': 'ER',
192-
'Grenada': 'GD',
193-
'Mozambique': 'MZ',
194-
'Papua New Guinea': 'PG',
195-
'Syria': 'SY',
196-
'Timor-Leste': 'TL',
197-
'Turks and Caicos': 'TC'
198-
};
1992

2003
exports.helpContent = `
2014
@@ -309,4 +112,16 @@ exports.countryNotFound = (isCurl) => {
309112
${footer(new Date)}
310113
`;
311114
return isCurl ? body : htmlTemplate(body);
115+
};
116+
117+
exports.stateCountryNotFound = (isCurl) => {
118+
const body = `
119+
State wise api is only available for:
120+
- US
121+
Try:
122+
/US or /USA
123+
124+
${footer(new Date)}
125+
`;
126+
return isCurl ? body : htmlTemplate(body);
312127
};

0 commit comments

Comments
 (0)