@quintype/framework 7.34.2-refactor-dfns.0 → 7.34.2-test-jsembed.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/framework",
|
|
3
|
-
"version": "7.34.2-
|
|
3
|
+
"version": "7.34.2-test-jsembed.0",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
34
34
|
"@grpc/grpc-js": "^1.12.5",
|
|
35
35
|
"@jsdoc/salty": "^0.2.9",
|
|
36
|
-
"@quintype/amp": "^2.21.1",
|
|
36
|
+
"@quintype/amp": "^2.21.2-test-jsembed.1",
|
|
37
37
|
"@quintype/backend": "^2.7.0",
|
|
38
38
|
"@quintype/components": "^3.5.0",
|
|
39
39
|
"@quintype/prerender-node": "^3.2.26",
|
|
@@ -204,7 +204,6 @@ function createStoreFromResult(url, result, opts = {}) {
|
|
|
204
204
|
primaryHostUrl: result.primaryHostUrl,
|
|
205
205
|
isBotRequest: isBotRequest,
|
|
206
206
|
lazyLoadImageMargin: opts.lazyLoadImageMargin,
|
|
207
|
-
localeModule: _.get(opts, ['localeModule'])
|
|
208
207
|
};
|
|
209
208
|
return createBasicStore(result, qt, opts);
|
|
210
209
|
}
|
|
@@ -472,7 +471,7 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
472
471
|
) {
|
|
473
472
|
const url = urlLib.parse(req.url, true);
|
|
474
473
|
|
|
475
|
-
function writeResponse(result
|
|
474
|
+
function writeResponse(result) {
|
|
476
475
|
const statusCode = result.httpStatusCode || 200;
|
|
477
476
|
|
|
478
477
|
if (statusCode == 301 && result.data && result.data.location) {
|
|
@@ -492,7 +491,6 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
492
491
|
const store = createStoreFromResult(url, result, {
|
|
493
492
|
disableIsomorphicComponent: statusCode != 200,
|
|
494
493
|
lazyLoadImageMargin,
|
|
495
|
-
localeModule: _.get(opts, ['localeModule'])
|
|
496
494
|
});
|
|
497
495
|
|
|
498
496
|
if (lightPages) {
|
|
@@ -555,55 +553,20 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
|
|
|
555
553
|
logError(e);
|
|
556
554
|
return { httpStatusCode: 500, pageType: "error" };
|
|
557
555
|
})
|
|
558
|
-
.then(
|
|
556
|
+
.then((result) => {
|
|
559
557
|
if (!result) {
|
|
560
558
|
return next();
|
|
561
559
|
}
|
|
562
|
-
return
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
});
|
|
571
|
-
})
|
|
560
|
+
return new Promise((resolve) => resolve(writeResponse(result)))
|
|
561
|
+
.catch((e) => {
|
|
562
|
+
logError(e);
|
|
563
|
+
res.status(500);
|
|
564
|
+
res.send(e.message);
|
|
565
|
+
})
|
|
566
|
+
.finally(() => res.end());
|
|
567
|
+
});
|
|
572
568
|
};
|
|
573
569
|
|
|
574
|
-
async function getStoreOpts(config) {
|
|
575
|
-
const opts = {};
|
|
576
|
-
const enableTimeTranslation = _.get(config, ['pbConfig', 'general', 'enableTimeTranslation'], false);
|
|
577
|
-
if (!enableTimeTranslation) {
|
|
578
|
-
return Promise.resolve(opts);
|
|
579
|
-
}
|
|
580
|
-
const languageCode = _.get(config, ['language', 'ietf-code']);
|
|
581
|
-
try {
|
|
582
|
-
let localeModule;
|
|
583
|
-
switch (languageCode) {
|
|
584
|
-
case 'hi':
|
|
585
|
-
localeModule = require('date-fns/locale/hi');
|
|
586
|
-
break;
|
|
587
|
-
case 'ta':
|
|
588
|
-
localeModule = require('date-fns/locale/ta');
|
|
589
|
-
break;
|
|
590
|
-
case 'de':
|
|
591
|
-
localeModule = require('date-fns/locale/de');
|
|
592
|
-
break;
|
|
593
|
-
default:
|
|
594
|
-
localeModule = require('date-fns/locale/en-US');
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
opts.localeModule = localeModule.default || localeModule;
|
|
598
|
-
return Promise.resolve(opts);
|
|
599
|
-
} catch (err) {
|
|
600
|
-
console.warn(`Falling back to en-US due to error loading locale: ${languageCode}`, err);
|
|
601
|
-
const fallbackLocale = require('date-fns/locale/en-US');
|
|
602
|
-
opts.localeModule = fallbackLocale.default || fallbackLocale;
|
|
603
|
-
return Promise.resolve(opts);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
570
|
exports.handleStaticRoute = function handleStaticRoute(
|
|
608
571
|
req,
|
|
609
572
|
res,
|