@quintype/framework 7.33.1-qttracelogs.3 → 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 +7 -0
- package/package.json +3 -5
- package/server/handlers/isomorphic-handler.js +4 -2
- package/server/routes.js +15 -32
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
|
|
3
|
+
"version": "7.33.1",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -31,9 +31,8 @@
|
|
|
31
31
|
"homepage": "https://github.com/quintype/quintype-node-framework#readme",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
34
|
-
"@jsdoc/salty": "^0.2.9",
|
|
35
34
|
"@quintype/amp": "^2.20.0",
|
|
36
|
-
"@quintype/backend": "^2.7.
|
|
35
|
+
"@quintype/backend": "^2.7.0",
|
|
37
36
|
"@quintype/components": "^3.5.0",
|
|
38
37
|
"@quintype/prerender-node": "^3.2.26",
|
|
39
38
|
"@quintype/seo": "^1.46.1",
|
|
@@ -60,7 +59,6 @@
|
|
|
60
59
|
"redux": "^4.1.1",
|
|
61
60
|
"request-promise": "^4.2.6",
|
|
62
61
|
"sleep-promise": "^9.1.0",
|
|
63
|
-
"uuid": "^11.0.5",
|
|
64
62
|
"winston": "3.3.3"
|
|
65
63
|
},
|
|
66
64
|
"devDependencies": {
|
|
@@ -75,7 +73,7 @@
|
|
|
75
73
|
"babel-preset-es2015-tree-shaking": "^1.0.1",
|
|
76
74
|
"babel-preset-react": "^6.24.1",
|
|
77
75
|
"babel-register": "^6.26.0",
|
|
78
|
-
"better-docs": "^2.
|
|
76
|
+
"better-docs": "^2.3.2",
|
|
79
77
|
"eslint": "^7.32.0",
|
|
80
78
|
"eslint-config-prettier": "^8.3.0",
|
|
81
79
|
"eslint-config-standard": "^16.0.3",
|
|
@@ -123,8 +123,10 @@ function loadDataForPageType(
|
|
|
123
123
|
)
|
|
124
124
|
)
|
|
125
125
|
.then((result) => {
|
|
126
|
-
if (result && result.data
|
|
127
|
-
|
|
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,14 +64,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
|
|
|
65
64
|
})
|
|
66
65
|
|
|
67
66
|
apiProxy.on('proxyReq', (proxyReq, req, res, options) => {
|
|
68
|
-
console.log("INSIDE PROXY", req.originalUrl);
|
|
69
|
-
console.log("GENERTATING QT TRACE ID API PROXY FROM HEADERS", (req && req.headers && req.headers['qt-trace-id']));
|
|
70
|
-
|
|
71
|
-
const qtTraceId = (req && req.headers && req.headers['qt-trace-id']) || uuidv4();
|
|
72
|
-
|
|
73
|
-
console.log("GENERTATING QT TRACE ID API PROXY", qtTraceId);
|
|
74
67
|
proxyReq.setHeader('Host', getClient(req.hostname).getHostname())
|
|
75
|
-
proxyReq.setHeader('qt-trace-id', qtTraceId)
|
|
76
68
|
})
|
|
77
69
|
|
|
78
70
|
const _sMaxAge = get(config, ['publisher', 'upstreamRoutesSmaxage'], sMaxAge)
|
|
@@ -103,15 +95,7 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
|
|
|
103
95
|
}
|
|
104
96
|
})
|
|
105
97
|
|
|
106
|
-
const sketchesProxy = (req, res) =>
|
|
107
|
-
// Attach QT-TRACE-ID to all the request going to sketches.
|
|
108
|
-
console.log("INSIDE SKETCHES PROXY", req.originalUrl);
|
|
109
|
-
console.log("INSIDE SKETCHES PROXY QT TRACE ID FROM HEADERS", (req && req.headers && req.headers['qt-trace-id']))
|
|
110
|
-
const qtTraceId = (req && req.headers && req.headers['qt-trace-id']) || uuidv4();
|
|
111
|
-
console.log("INSIDE SKETCHES PROXY GENERATING QT TRACE ID", qtTraceId)
|
|
112
|
-
req.headers['qt-trace-id'] = qtTraceId;
|
|
113
|
-
return apiProxy.web(req, res);
|
|
114
|
-
};
|
|
98
|
+
const sketchesProxy = (req, res) => apiProxy.web(req, res)
|
|
115
99
|
|
|
116
100
|
app.get('/ping', (req, res) => {
|
|
117
101
|
getClient(req.hostname)
|
|
@@ -162,12 +146,12 @@ exports.upstreamQuintypeRoutes = function upstreamQuintypeRoutes(
|
|
|
162
146
|
}
|
|
163
147
|
|
|
164
148
|
// istanbul ignore next
|
|
165
|
-
function renderServiceWorkerFn(res, layout, params, callback) {
|
|
149
|
+
function renderServiceWorkerFn (res, layout, params, callback) {
|
|
166
150
|
return res.render(layout, params, callback)
|
|
167
151
|
}
|
|
168
152
|
|
|
169
153
|
// istanbul ignore next
|
|
170
|
-
function toFunction(value, toRequire) {
|
|
154
|
+
function toFunction (value, toRequire) {
|
|
171
155
|
if (value === true) {
|
|
172
156
|
value = require(toRequire)
|
|
173
157
|
}
|
|
@@ -178,20 +162,20 @@ function toFunction(value, toRequire) {
|
|
|
178
162
|
return () => value
|
|
179
163
|
}
|
|
180
164
|
|
|
181
|
-
function getDomainSlug(publisherConfig, hostName) {
|
|
165
|
+
function getDomainSlug (publisherConfig, hostName) {
|
|
182
166
|
if (!publisherConfig.domain_mapping) {
|
|
183
167
|
return undefined
|
|
184
168
|
}
|
|
185
169
|
return publisherConfig.domain_mapping[hostName] || null
|
|
186
170
|
}
|
|
187
171
|
|
|
188
|
-
function withConfigPartial(
|
|
172
|
+
function withConfigPartial (
|
|
189
173
|
getClient,
|
|
190
174
|
logError,
|
|
191
175
|
publisherConfig = require('./publisher-config'),
|
|
192
176
|
configWrapper = config => config
|
|
193
177
|
) {
|
|
194
|
-
return function withConfig(f, staticParams) {
|
|
178
|
+
return function withConfig (f, staticParams) {
|
|
195
179
|
return function (req, res, next) {
|
|
196
180
|
const domainSlug = getDomainSlug(publisherConfig, req.hostname)
|
|
197
181
|
const client = getClient(req.hostname)
|
|
@@ -215,7 +199,7 @@ function withConfigPartial(
|
|
|
215
199
|
}
|
|
216
200
|
}
|
|
217
201
|
|
|
218
|
-
exports.withError = function withError(handler, logError) {
|
|
202
|
+
exports.withError = function withError (handler, logError) {
|
|
219
203
|
return async (req, res, next, opts) => {
|
|
220
204
|
try {
|
|
221
205
|
await handler(req, res, next, opts)
|
|
@@ -227,15 +211,15 @@ exports.withError = function withError(handler, logError) {
|
|
|
227
211
|
}
|
|
228
212
|
}
|
|
229
213
|
|
|
230
|
-
function convertToDomain(path) {
|
|
214
|
+
function convertToDomain (path) {
|
|
231
215
|
if (!path) {
|
|
232
216
|
return path
|
|
233
217
|
}
|
|
234
218
|
return new URL(path).origin
|
|
235
219
|
}
|
|
236
220
|
|
|
237
|
-
function wrapLoadDataWithMultiDomain(publisherConfig, f, configPos) {
|
|
238
|
-
return async function loadDataWrapped() {
|
|
221
|
+
function wrapLoadDataWithMultiDomain (publisherConfig, f, configPos) {
|
|
222
|
+
return async function loadDataWrapped () {
|
|
239
223
|
const { domainSlug } = arguments[arguments.length - 1]
|
|
240
224
|
const config = arguments[configPos]
|
|
241
225
|
const primaryHostUrl = convertToDomain(config['sketches-host'])
|
|
@@ -273,7 +257,7 @@ function wrapLoadDataWithMultiDomain(publisherConfig, f, configPos) {
|
|
|
273
257
|
* @param {module:routes~Handler} handler The Handler to run
|
|
274
258
|
* @param {Object} opts Options that will be passed to the handler. These options will be merged with a *config* and *client*
|
|
275
259
|
*/
|
|
276
|
-
function getWithConfig(app, route, handler, opts = {}) {
|
|
260
|
+
function getWithConfig (app, route, handler, opts = {}) {
|
|
277
261
|
const configWrapper = opts.configWrapper
|
|
278
262
|
const {
|
|
279
263
|
getClient = require('./api-client').getClient,
|
|
@@ -325,7 +309,7 @@ function getWithConfig(app, route, handler, opts = {}) {
|
|
|
325
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)
|
|
326
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"
|
|
327
311
|
*/
|
|
328
|
-
exports.isomorphicRoutes = function isomorphicRoutes(
|
|
312
|
+
exports.isomorphicRoutes = function isomorphicRoutes (
|
|
329
313
|
app,
|
|
330
314
|
{
|
|
331
315
|
generateRoutes,
|
|
@@ -640,13 +624,12 @@ exports.getWithConfig = getWithConfig
|
|
|
640
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"*)
|
|
641
625
|
*/
|
|
642
626
|
exports.proxyGetRequest = function (app, route, handler, opts = {}) {
|
|
643
|
-
|
|
644
627
|
const { logError = require('./logger').error } = opts
|
|
645
628
|
const { cacheControl = 'public,max-age=15,s-maxage=240,stale-while-revalidate=300,stale-if-error=3600' } = opts
|
|
646
629
|
|
|
647
630
|
getWithConfig(app, route, proxyHandler, opts)
|
|
648
631
|
|
|
649
|
-
async function proxyHandler(req, res, next, { config, client }) {
|
|
632
|
+
async function proxyHandler (req, res, next, { config, client }) {
|
|
650
633
|
try {
|
|
651
634
|
const result = await handler(req.params, { config, client })
|
|
652
635
|
if (typeof result === 'string' && result.startsWith('http')) {
|
|
@@ -659,7 +642,7 @@ exports.proxyGetRequest = function (app, route, handler, opts = {}) {
|
|
|
659
642
|
sendResult(null)
|
|
660
643
|
}
|
|
661
644
|
|
|
662
|
-
function sendResult(result) {
|
|
645
|
+
function sendResult (result) {
|
|
663
646
|
if (result) {
|
|
664
647
|
res.setHeader('Cache-Control', cacheControl)
|
|
665
648
|
res.setHeader('Vary', 'Accept-Encoding')
|