@quintype/framework 7.21.2 → 7.22.0-config-amp-story-path.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/routes.js +13 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.21.2",
3
+ "version": "7.22.0-config-amp-story-path.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
package/server/routes.js CHANGED
@@ -70,7 +70,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
70
70
  const _sMaxAge = get(config, ["publisher", "upstreamRoutesSmaxage"], sMaxAge);
71
71
  const _maxAge = get(config, ["publisher", "upstreamRoutesMaxage"], maxAge);
72
72
 
73
- parseInt(_sMaxAge) > 0 &&
73
+ parseInt(_sMaxAge) > 0 &&
74
74
  apiProxy.on("proxyRes", function (proxyRes, req) {
75
75
  const pathName = get(req, ["originalUrl"], "").split("?")[0];
76
76
  const checkForExcludeRoutes = excludeRoutes.some((path) => {
@@ -79,8 +79,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
79
79
  });
80
80
  const getCacheControl = get(proxyRes, ["headers", "cache-control"], "");
81
81
  if (!checkForExcludeRoutes && getCacheControl.includes("public")) {
82
- proxyRes.headers["cache-control"] = getCacheControl
83
- .replace(/s-maxage=\d*/g, `s-maxage=${_sMaxAge}`);
82
+ proxyRes.headers["cache-control"] = getCacheControl.replace(/s-maxage=\d*/g, `s-maxage=${_sMaxAge}`);
84
83
  }
85
84
  });
86
85
  parseInt(_maxAge) > 0 &&
@@ -92,8 +91,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
92
91
  });
93
92
  const getCacheControl = get(proxyRes, ["headers", "cache-control"], "");
94
93
  if (!checkForExcludeRoutes && getCacheControl.includes("public")) {
95
- proxyRes.headers["cache-control"] = getCacheControl
96
- .replace(/max-age=\d*/g, `max-age=${_maxAge}`);
94
+ proxyRes.headers["cache-control"] = getCacheControl.replace(/max-age=\d*/g, `max-age=${_maxAge}`);
97
95
  }
98
96
  });
99
97
 
@@ -665,7 +663,16 @@ exports.mountQuintypeAt = function (app, mountAt) {
665
663
  exports.ampRoutes = (app, opts = {}) => {
666
664
  const { ampStoryPageHandler, storyPageInfiniteScrollHandler } = require("./amp/handlers");
667
665
 
668
- getWithConfig(app, "/amp/story/*", ampStoryPageHandler, opts);
666
+ let ampPageBasePath = "/amp/story";
667
+ if (opts.featureConfig) {
668
+ const configAmpPath =
669
+ typeof opts.featureConfig.ampPageBasePath === "function"
670
+ ? opts.featureConfig.ampPageBasePath()
671
+ : opts.featureConfig.ampPageBasePath;
672
+ ampPageBasePath = configAmpPath || ampPageBasePath;
673
+ }
674
+
675
+ getWithConfig(app, `${ampPageBasePath}/*`, ampStoryPageHandler, opts);
669
676
  getWithConfig(app, "/amp/api/v1/amp-infinite-scroll", storyPageInfiniteScrollHandler, opts);
670
677
  getWithConfig(app, "/ampstories/*", ampStoryPageHandler, { ...opts, isVisualStory: true });
671
678
  };