@quintype/framework 7.33.1-qttracelogs.1 → 7.33.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [7.33.1](https://github.com/quintype/quintype-node-framework/compare/v7.33.0...v7.33.1) (2025-01-20)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **Static routes:** support 404 if no loader ([#452](https://github.com/quintype/quintype-node-framework/issues/452)) ([735b778](https://github.com/quintype/quintype-node-framework/commit/735b77887ae0359b85fde8db1a203f7576244a3b))
11
+
5
12
  ## [7.33.0](https://github.com/quintype/quintype-node-framework/compare/v7.32.0...v7.33.0) (2024-12-10)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.33.1-qttracelogs.1",
3
+ "version": "7.33.1",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@ampproject/toolbox-optimizer": "2.8.3",
34
34
  "@quintype/amp": "^2.20.0",
35
- "@quintype/backend": "^2.7.2-qttracelogs.0",
35
+ "@quintype/backend": "^2.7.0",
36
36
  "@quintype/components": "^3.5.0",
37
37
  "@quintype/prerender-node": "^3.2.26",
38
38
  "@quintype/seo": "^1.46.1",
@@ -59,7 +59,6 @@
59
59
  "redux": "^4.1.1",
60
60
  "request-promise": "^4.2.6",
61
61
  "sleep-promise": "^9.1.0",
62
- "uuid": "^11.0.5",
63
62
  "winston": "3.3.3"
64
63
  },
65
64
  "devDependencies": {
@@ -123,8 +123,10 @@ function loadDataForPageType(
123
123
  )
124
124
  )
125
125
  .then((result) => {
126
- if (result && result.data && result.data[ABORT_HANDLER]) {
127
- return null;
126
+ if (result && result.data) {
127
+ if (result.data[ABORT_HANDLER] || (result.data.error && result.data.error.message)) {
128
+ return null
129
+ }
128
130
  }
129
131
  return result;
130
132
  })
package/server/routes.js CHANGED
@@ -29,7 +29,6 @@ const bodyParser = require('body-parser')
29
29
  const get = require('lodash/get')
30
30
  const { URL } = require('url')
31
31
  const prerender = require('@quintype/prerender-node')
32
- const { v4: uuidv4 } = require('uuid');
33
32
 
34
33
  /**
35
34
  * *upstreamQuintypeRoutes* connects various routes directly to the upstream API server.
@@ -44,7 +43,7 @@ const { v4: uuidv4 } = require('uuid');
44
43
  * @param {boolean} opts.forwardFavicon Forward favicon requests to the CMS (default false)
45
44
  * @param {boolean} opts.isSitemapUrlEnabled To enable /news_sitemap/today and /news_sitemap/yesterday sitemap news url (default /news_sitemap.xml)
46
45
  */
47
- exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
46
+ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes (
48
47
  app,
49
48
  {
50
49
  forwardAmp = false,
@@ -65,9 +64,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
65
64
  })
66
65
 
67
66
  apiProxy.on('proxyReq', (proxyReq, req, res, options) => {
68
- const qtTraceId = (req && req.headers && req.headers['qt-trace-id']) || uuidv4();
69
67
  proxyReq.setHeader('Host', getClient(req.hostname).getHostname())
70
- proxyReq.setHeader('qt-trace-id', qtTraceId)
71
68
  })
72
69
 
73
70
  const _sMaxAge = get(config, ['publisher', 'upstreamRoutesSmaxage'], sMaxAge)
@@ -98,12 +95,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
98
95
  }
99
96
  })
100
97
 
101
- const sketchesProxy = (req, res) => {
102
- // Attach QT-TRACE-ID to all the request going to sketches.
103
- const qtTraceId = (req && req.headers && req.headers['qt-trace-id']) || uuidv4();
104
- req.headers['qt-trace-id'] = qtTraceId;
105
- return apiProxy.web(req, res);
106
- };
98
+ const sketchesProxy = (req, res) => apiProxy.web(req, res)
107
99
 
108
100
  app.get('/ping', (req, res) => {
109
101
  getClient(req.hostname)
@@ -154,12 +146,12 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
154
146
  }
155
147
 
156
148
  // istanbul ignore next
157
- function renderServiceWorkerFn(res, layout, params, callback) {
149
+ function renderServiceWorkerFn (res, layout, params, callback) {
158
150
  return res.render(layout, params, callback)
159
151
  }
160
152
 
161
153
  // istanbul ignore next
162
- function toFunction(value, toRequire) {
154
+ function toFunction (value, toRequire) {
163
155
  if (value === true) {
164
156
  value = require(toRequire)
165
157
  }
@@ -170,20 +162,20 @@ function toFunction(value, toRequire) {
170
162
  return () => value
171
163
  }
172
164
 
173
- function getDomainSlug(publisherConfig, hostName) {
165
+ function getDomainSlug (publisherConfig, hostName) {
174
166
  if (!publisherConfig.domain_mapping) {
175
167
  return undefined
176
168
  }
177
169
  return publisherConfig.domain_mapping[hostName] || null
178
170
  }
179
171
 
180
- function withConfigPartial(
172
+ function withConfigPartial (
181
173
  getClient,
182
174
  logError,
183
175
  publisherConfig = require('./publisher-config'),
184
176
  configWrapper = config => config
185
177
  ) {
186
- return function withConfig(f, staticParams) {
178
+ return function withConfig (f, staticParams) {
187
179
  return function (req, res, next) {
188
180
  const domainSlug = getDomainSlug(publisherConfig, req.hostname)
189
181
  const client = getClient(req.hostname)
@@ -207,7 +199,7 @@ function withConfigPartial(
207
199
  }
208
200
  }
209
201
 
210
- exports.withError = function withError(handler, logError) {
202
+ exports.withError = function withError (handler, logError) {
211
203
  return async (req, res, next, opts) => {
212
204
  try {
213
205
  await handler(req, res, next, opts)
@@ -219,15 +211,15 @@ exports.withError = function withError(handler, logError) {
219
211
  }
220
212
  }
221
213
 
222
- function convertToDomain(path) {
214
+ function convertToDomain (path) {
223
215
  if (!path) {
224
216
  return path
225
217
  }
226
218
  return new URL(path).origin
227
219
  }
228
220
 
229
- function wrapLoadDataWithMultiDomain(publisherConfig, f, configPos) {
230
- return async function loadDataWrapped() {
221
+ function wrapLoadDataWithMultiDomain (publisherConfig, f, configPos) {
222
+ return async function loadDataWrapped () {
231
223
  const { domainSlug } = arguments[arguments.length - 1]
232
224
  const config = arguments[configPos]
233
225
  const primaryHostUrl = convertToDomain(config['sketches-host'])
@@ -265,7 +257,7 @@ function wrapLoadDataWithMultiDomain(publisherConfig, f, configPos) {
265
257
  * @param {module:routes~Handler} handler The Handler to run
266
258
  * @param {Object} opts Options that will be passed to the handler. These options will be merged with a *config* and *client*
267
259
  */
268
- function getWithConfig(app, route, handler, opts = {}) {
260
+ function getWithConfig (app, route, handler, opts = {}) {
269
261
  const configWrapper = opts.configWrapper
270
262
  const {
271
263
  getClient = require('./api-client').getClient,
@@ -317,7 +309,7 @@ function getWithConfig(app, route, handler, opts = {}) {
317
309
  * @param {boolean|function} enableExternalStories If set to true, then for every request an external story api call is made and renders the story-page if the story is found. (default: false)
318
310
  * @param {string|function} externalIdPattern This string specifies the external id pattern the in the url. Mention `EXTERNAL_ID` to specify the position of external id in the url. Ex: "/parent-section/child-section/EXTERNAL_ID"
319
311
  */
320
- exports.isomorphicRoutes = function isomorphicRoutes(
312
+ exports.isomorphicRoutes = function isomorphicRoutes (
321
313
  app,
322
314
  {
323
315
  generateRoutes,
@@ -632,13 +624,12 @@ exports.getWithConfig = getWithConfig
632
624
  * @param opts.cacheControl The cache control header to set on proxied requests (default: *"public,max-age=15,s-maxage=240,stale-while-revalidate=300,stale-if-error=3600"*)
633
625
  */
634
626
  exports.proxyGetRequest = function (app, route, handler, opts = {}) {
635
-
636
627
  const { logError = require('./logger').error } = opts
637
628
  const { cacheControl = 'public,max-age=15,s-maxage=240,stale-while-revalidate=300,stale-if-error=3600' } = opts
638
629
 
639
630
  getWithConfig(app, route, proxyHandler, opts)
640
631
 
641
- async function proxyHandler(req, res, next, { config, client }) {
632
+ async function proxyHandler (req, res, next, { config, client }) {
642
633
  try {
643
634
  const result = await handler(req.params, { config, client })
644
635
  if (typeof result === 'string' && result.startsWith('http')) {
@@ -651,7 +642,7 @@ exports.proxyGetRequest = function (app, route, handler, opts = {}) {
651
642
  sendResult(null)
652
643
  }
653
644
 
654
- function sendResult(result) {
645
+ function sendResult (result) {
655
646
  if (result) {
656
647
  res.setHeader('Cache-Control', cacheControl)
657
648
  res.setHeader('Vary', 'Accept-Encoding')