@@ -7,14 +7,17 @@ import {encryptAES, decryptAES} from './crypto.js';
77// dev env
88dotenv . config ( ) ;
99
10+ // application secrets
11+ // import { keys } from './config/keys.js';
12+
1013let EXCHANGE_RATE_APIKEY ;
1114let BASE_URI ;
1215let SAMPLE2_URI ;
1316let WEATHERBIT_KEY ;
1417let WEATHERBIT_URI ;
1518let GoogleclientID ;
1619let GoogleclientSecret ;
17- // if (process.env.NODE_ENV === "production") {
20+ if ( process . env . NODE_ENV === "production" ) {
1821 EXCHANGE_RATE_APIKEY = process . env . EXCHANGE_RATE_APIKEY ;
1922 BASE_URI = process . env . EXCHANGE_BASE_URI ;
2023 SAMPLE2_URI = process . env . SAMPLE2_URI ;
@@ -23,25 +26,25 @@ let GoogleclientSecret;
2326 GoogleclientID = process . env . GoogleclientID ;
2427 GoogleclientSecret = process . env . GoogleclientSecret ;
2528
26- //} else {
27- // // dynamically importing keys.js:
28- // let AppKeys = await import('./config/keys.js');
29- // EXCHANGE_RATE_APIKEY = AppKeys.exchangerateapi.APIKEY;
30- // BASE_URI = AppKeys.exchangerateapi.BASE_URI;
31- // SAMPLE2_URI = AppKeys.exchangerateapi.SAMPLE2_URI;
32- // WEATHERBIT_KEY = AppKeys.weatherbitapi.APIKEY;
33- // WEATHERBIT_URI = AppKeys.weatherbitapi.BASE_URI;
34- // GoogleclientID = AppKeys.google.clientID;
35- // GoogleclientSecret = AppKeys.google.clientSecre;
36- // }
29+ } else {
30+ // dynamically importing keys.js using promise:
31+ import ( './config/keys.js' ) . then ( ( secrets ) => {
32+ EXCHANGE_RATE_APIKEY = secrets . keys . exchangerateapi . EXCHANGE_APIKEY ;
33+ BASE_URI = secrets . keys . exchangerateapi . EXCHANGE_BASE_URI ;
34+ SAMPLE2_URI = secrets . keys . exchangerateapi . SAMPLE2_URI ;
35+ WEATHERBIT_KEY = secrets . keys . weatherbitapi . WEATHERBIT_APIKEY ;
36+ WEATHERBIT_URI = secrets . keys . weatherbitapi . WEATHERBIT_BASE_URI ;
37+ GoogleclientID = secrets . keys . google . clientID ;
38+ GoogleclientSecret = secrets . keys . google . clientSecret ;
39+ } ) ;
40+
41+ }
3742
3843
3944
4045// Create network routing
4146const app = express ( ) ;
4247
43- // application secrets
44- import { keys } from './config/keys.js' ;
4548
4649// routes handler for Currency Exchange methods
4750import { router as currencyExchangeRoutes } from './routes/currency-exchange-routes.js' ;
0 commit comments