Skip to content

Commit 4bfbc6e

Browse files
committed
Misc updates related to ContentfulLoader
- Support of local execution against non-Topcoder Contentful account; - Shortcuts Contentful services to not use Topcoder CDN as proxy; - Updates all code related to dashboard announcements to use ContentfulLoader.
1 parent 76272a7 commit 4bfbc6e

File tree

13 files changed

+124
-542
lines changed

13 files changed

+124
-542
lines changed

.exchange-rates.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1525957200,"base":"USD","rates":{"AED":3.673158,"AFN":70.802,"ALL":106.5,"AMD":486.650001,"ANG":1.797006,"AOA":232.0125,"ARS":22.6815,"AUD":1.328477,"AWG":1.789995,"AZN":1.7025,"BAM":1.646604,"BBD":2,"BDT":84.81695,"BGN":1.640044,"BHD":0.377017,"BIF":1763.65,"BMD":1,"BND":1.332,"BOB":6.91755,"BRL":3.554857,"BSD":1,"BTC":0.000107021526,"BTN":67.351093,"BWP":9.925416,"BYN":2.029813,"BZD":2.011991,"CAD":1.276777,"CDF":1613.322925,"CHF":1.000284,"CLF":0.02298,"CLP":627.555,"CNH":6.337328,"CNY":6.34585,"COP":2817.460317,"CRC":566.93,"CUC":1,"CUP":25.5,"CVE":92.8335,"CZK":21.379904,"DJF":176.955,"DKK":6.24568,"DOP":49.64,"DZD":115.6885,"EGP":17.7206,"ERN":14.995,"ETB":27.545748,"EUR":0.838434,"FJD":2.091847,"FKP":0.739123,"GBP":0.739123,"GEL":2.446238,"GGP":0.739123,"GHS":4.541501,"GIP":0.739123,"GMD":47.1775,"GNF":9034.8,"GTQ":7.430487,"GYD":208.958026,"HKD":7.8496,"HNL":23.763117,"HRK":6.195006,"HTG":65.293,"HUF":263.2555,"IDR":14077.984358,"ILS":3.573487,"IMP":0.739123,"INR":67.2655,"IQD":1192.850723,"IRR":37453.047379,"ISK":102.616601,"JEP":0.739123,"JMD":125.337176,"JOD":0.709503,"JPY":109.42383333,"KES":100.454,"KGS":68.743499,"KHR":4061.5,"KMF":414.725,"KPW":900,"KRW":1068.66,"KWD":0.3016,"KYD":0.834244,"KZT":330.495546,"LAK":8338.5,"LBP":1509.587443,"LKR":158.155049,"LRD":132.194113,"LSL":12.627664,"LYD":1.35783,"MAD":9.37175,"MDL":16.538588,"MGA":3248.2,"MKD":51.815849,"MMK":1347.5,"MNT":2397.686339,"MOP":8.094082,"MRO":356,"MRU":35.691667,"MUR":34.494575,"MVR":15.509851,"MWK":720.465,"MXN":19.3415,"MYR":4.016307,"MZN":59.945,"NAD":12.61945,"NGN":360.36226,"NIO":31.362247,"NOK":7.995325,"NPR":107.770821,"NZD":1.436213,"OMR":0.385005,"PAB":1,"PEN":3.293102,"PGK":3.252,"PHP":51.995,"PKR":115.897708,"PLN":3.553483,"PYG":5614.75,"QAR":3.640999,"RON":3.890533,"RSD":99.09575,"RUB":61.891267,"RWF":869.74,"SAR":3.751301,"SBD":7.822579,"SCR":13.45475,"SDG":18.205295,"SEK":8.62824,"SGD":1.338703,"SHP":0.739123,"SLL":7762.034972,"SOS":579.055,"SRD":7.468,"SSP":130.2634,"STD":20603.211685,"STN":20.7,"SVC":8.758397,"SYP":514.94999,"SZL":12.440299,"THB":32.00875,"TJS":8.981686,"TMT":3.499986,"TND":2.527016,"TOP":2.218188,"TRY":4.23042,"TTD":6.74685,"TWD":29.784361,"TZS":2281.9,"UAH":26.2552,"UGX":3718.65,"USD":1,"UYU":29.082348,"UZS":8067.05,"VEF":69922.5,"VND":22770.944472,"VUV":108.579988,"WST":2.55968,"XAF":549.976775,"XAG":0.05978546,"XAU":0.00075634,"XCD":2.70255,"XDR":0.700936,"XOF":549.976775,"XPD":0.00101076,"XPF":100.051812,"XPT":0.00108549,"YER":250.306642,"ZAR":12.3317,"ZMW":9.9,"ZWL":322.355011}}
1+
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1526050800,"base":"USD","rates":{"AED":3.673281,"AFN":70.710962,"ALL":106.38,"AMD":485.695,"ANG":1.795715,"AOA":231.4755,"ARS":23.1748,"AUD":1.325261,"AWG":1.791244,"AZN":1.7025,"BAM":1.638591,"BBD":2,"BDT":84.75795,"BGN":1.637434,"BHD":0.376964,"BIF":1781,"BMD":1,"BND":1.3209,"BOB":6.912769,"BRL":3.58416,"BSD":1,"BTC":0.000115593037,"BTN":67.304626,"BWP":9.895515,"BYN":2.007408,"BZD":2.010791,"CAD":1.278478,"CDF":1615,"CHF":0.999819,"CLF":0.02261,"CLP":618.14,"CNH":6.328126,"CNY":6.33218,"COP":2801.425,"CRC":566.695059,"CUC":1,"CUP":25.5,"CVE":92.3795,"CZK":21.342439,"DJF":177.75,"DKK":6.237574,"DOP":49.455,"DZD":115.516125,"EGP":17.7,"ERN":14.998767,"ETB":27.5,"EUR":0.837252,"FJD":2.091148,"FKP":0.737843,"GBP":0.737843,"GEL":2.443508,"GGP":0.737843,"GHS":4.53,"GIP":0.737843,"GMD":47.18,"GNF":9030,"GTQ":7.43045,"GYD":209.314534,"HKD":7.849701,"HNL":23.660322,"HRK":6.1871,"HTG":65.244838,"HUF":263.737692,"IDR":13971.725015,"ILS":3.566515,"IMP":0.737843,"INR":67.345,"IQD":1187.5,"IRR":37453.047379,"ISK":102.495,"JEP":0.737843,"JMD":125.24995,"JOD":0.709506,"JPY":109.37981667,"KES":100.395,"KGS":68.700944,"KHR":4061,"KMF":414.725,"KPW":900,"KRW":1068.315,"KWD":0.3015,"KYD":0.833677,"KZT":327.47765,"LAK":8340,"LBP":1513.65,"LKR":157.905232,"LRD":132.18915,"LSL":12.595,"LYD":1.355,"MAD":9.361773,"MDL":16.539963,"MGA":3240,"MKD":51.56,"MMK":1346.55,"MNT":2397.6995,"MOP":8.088592,"MRO":355.5,"MRU":35.7,"MUR":34.446516,"MVR":15.509851,"MWK":721.045,"MXN":19.312336,"MYR":3.99805,"MZN":60.189545,"NAD":12.585,"NGN":360.5,"NIO":31.285,"NOK":7.993116,"NPR":107.702558,"NZD":1.436022,"OMR":0.384975,"PAB":1,"PEN":3.266209,"PGK":3.28825,"PHP":52.45,"PKR":115.568,"PLN":3.568029,"PYG":5606.1,"QAR":3.640999,"RON":3.879955,"RSD":99,"RUB":61.701,"RWF":865,"SAR":3.75035,"SBD":7.80896,"SCR":13.45505,"SDG":18,"SEK":8.590022,"SGD":1.335489,"SHP":0.737843,"SLL":7786.788251,"SOS":575,"SRD":7.468,"SSP":130.2634,"STD":20574.369681,"STN":20.7,"SVC":8.75317,"SYP":514.92499,"SZL":12.401761,"THB":31.90625,"TJS":8.976386,"TMT":3.50998,"TND":2.490696,"TOP":2.218713,"TRY":4.304889,"TTD":6.74255,"TWD":29.7585,"TZS":2283.15,"UAH":26.2125,"UGX":3716.5,"USD":1,"UYU":28.99,"UZS":8055,"VEF":69900,"VND":22771.156217,"VUV":107.747276,"WST":2.544003,"XAF":549.200993,"XAG":0.05965172,"XAU":0.00075625,"XCD":2.70255,"XDR":0.698904,"XOF":549.200993,"XPD":0.00100104,"XPF":99.910682,"XPT":0.00108109,"YER":250.306642,"ZAR":12.25322,"ZMW":9.899,"ZWL":322.355011}}

config/custom-environment-variables.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* counterparts from configuration files. */
33

44
module.exports = {
5+
CONTENTFUL: {
6+
LOCAL_MODE: 'CONTENTFUL_LOCAL_MODE',
7+
},
8+
59
LOG_ENTRIES_TOKEN: 'LOG_ENTRIES_TOKEN',
610
MOCK_TERMS_SERVICE: 'MOCK_TERMS_SERVICE',
711

config/default.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports = {
3131
* challenges once per this amount of seconds. */
3232
CHALLENGE_LISTING_AUTO_REFRESH: 300,
3333

34+
CONTENTFUL: {
35+
LOCAL_MODE: false,
36+
},
37+
3438
/* API token for logentries.com. The token below is just for local testing of
3539
* the setup. To override it use LOG_ENTRIES_TOKEN environment variable. */
3640
LOG_ENTRIES_TOKEN: '816f5574-0d4a-49f9-ab3b-00d791f7c1f7',
@@ -91,7 +95,7 @@ module.exports = {
9195
ARENA: 'https://arena.topcoder-dev.com',
9296
AUTH: 'http://accounts.topcoder-dev.com',
9397
BASE: 'https://www.topcoder-dev.com',
94-
BLOG: 'https://www.topcoder-dev.com/blog',
98+
BLOG: 'https://www.topcoder.com/blog',
9599
BLOG_FEED: 'https://www.topcoder-dev.com/feed',
96100
COMMUNITY: 'https://community.topcoder-dev.com',
97101
FORUMS: 'https://apps.topcoder-dev.com/forums',

src/server/routes/contentful.js

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import {
99
ASSETS_DOMAIN,
1010
IMAGES_DOMAIN,
1111
cdnService,
12-
getIndex,
13-
getCurrentDashboardAnnouncementId,
14-
getCurrentDashboardAnnouncementsIndex,
15-
getNextSyncUrl,
12+
// getIndex,
13+
// getNextSyncUrl,
1614
previewService,
1715
} from '../services/contentful';
1816

1917
const routes = express.Router();
2018

19+
const LOCAL_MODE = Boolean(config.CONTENTFUL.LOCAL_MODE);
20+
2121
/* Sets Access-Control-Allow-Origin header to avoid CORS error.
2222
* TODO: Replace the wildcard value by an appropriate origin filtering. */
2323
routes.use((req, res, next) => {
@@ -37,11 +37,13 @@ routes.use('/images/:id/:version/:name', (req, res) => {
3737

3838
/* Gets preview of the specified asset. */
3939
routes.use('/preview/assets/:id', (req, res, next) =>
40-
previewService.getAsset(req.params.id, true).then(res.send.bind(res), next));
40+
previewService.getAsset(req.params.id, !LOCAL_MODE)
41+
.then(res.send.bind(res), next));
4142

4243
/* Queries asset previews. */
4344
routes.use('/preview/assets', (req, res, next) =>
44-
previewService.queryAssets(req.query, true).then(res.send.bind(res), next));
45+
previewService.queryAssets(req.query, !LOCAL_MODE)
46+
.then(res.send.bind(res), next));
4547

4648
/* Gets preview of the specified entry. */
4749
routes.use('/preview/entries/:id', (req, res, next) =>
@@ -53,11 +55,13 @@ routes.use('/preview/entries', (req, res, next) =>
5355

5456
/* Gets the specified published asset. */
5557
routes.use('/published/assets/:id', (req, res, next) =>
56-
cdnService.getAsset(req.params.id, true).then(res.send.bind(res), next));
58+
cdnService.getAsset(req.params.id, !LOCAL_MODE)
59+
.then(res.send.bind(res), next));
5760

5861
/* Queries published assets. */
5962
routes.use('/published/assets', (req, res, next) =>
60-
cdnService.queryAssets(req.query, true).then(res.send.bind(res), next));
63+
cdnService.queryAssets(req.query, !LOCAL_MODE)
64+
.then(res.send.bind(res), next));
6165

6266
/* Gets the specified published entry. */
6367
routes.use('/published/entries/:id', (req, res, next) =>
@@ -67,38 +71,25 @@ routes.use('/published/entries/:id', (req, res, next) =>
6771
routes.use('/published/entries', (req, res, next) =>
6872
cdnService.queryEntries(req.query).then(res.send.bind(res), next));
6973

70-
/* Returns ID of the current dashboard announcement. */
71-
routes.use('/current-dashboard-announcement-id', async (req, res, next) => {
72-
try {
73-
res.set('Cache-Control', `max-age=${1000}`);
74-
res.send(await getCurrentDashboardAnnouncementId());
75-
} catch (err) { next(err); }
76-
});
77-
78-
/* Returns public index of current dashboard announcements. */
79-
routes.use('/current-dashboard-announcements-index', async (req, res, next)
80-
=> {
81-
try {
82-
res.set('Cache-Control', `max-age=${1000}`);
83-
res.send(await getCurrentDashboardAnnouncementsIndex());
84-
} catch (err) { next(err); }
85-
});
86-
8774
/* Returns index of assets and content. */
75+
/*
8876
routes.use('/index', async (req, res, next) => {
8977
try {
9078
res.set('Cache-Control', `max-age=${1000}`);
9179
res.send(await getIndex());
9280
} catch (err) { next(err); }
9381
});
82+
*/
9483

9584
/* Returns URL for the next sync of assets and content index with Contentful
9685
* API. */
86+
/*
9787
routes.use('/next-sync-url', async (req, res, next) => {
9888
try {
9989
res.set('Cache-Control', `max-age=${1000}`);
10090
res.send(await getNextSyncUrl());
10191
} catch (err) { next(err); }
10292
});
93+
*/
10394

10495
export default routes;

0 commit comments

Comments
 (0)