@quintype/framework 7.7.3 → 7.7.4
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,8 @@
|
|
|
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.7.4](https://github.com/quintype/quintype-node-framework/compare/v7.7.3...v7.7.4) (2022-07-13)
|
|
6
|
+
|
|
5
7
|
### [7.7.3](https://github.com/quintype/quintype-node-framework/compare/v7.7.2...v7.7.3) (2022-07-13)
|
|
6
8
|
|
|
7
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/framework",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.4",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"homepage": "https://github.com/quintype/quintype-node-framework#readme",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
34
|
-
"@quintype/amp": "^2.4.
|
|
34
|
+
"@quintype/amp": "^2.4.25",
|
|
35
35
|
"@quintype/backend": "^2.3.1",
|
|
36
36
|
"@quintype/components": "^3.0.0",
|
|
37
37
|
"@quintype/prerender-node": "^3.2.24",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const { ampStoryPageHandler } = require("./story-page");
|
|
2
2
|
const { storyPageInfiniteScrollHandler } = require("./infinite-scroll");
|
|
3
|
-
const { bookendHandler } = require("./visual-stories-bookend");
|
|
4
3
|
|
|
5
4
|
module.exports = {
|
|
6
5
|
ampStoryPageHandler,
|
|
7
6
|
storyPageInfiniteScrollHandler,
|
|
8
|
-
bookendHandler,
|
|
9
7
|
};
|
package/server/routes.js
CHANGED
|
@@ -626,10 +626,9 @@ exports.mountQuintypeAt = function (app, mountAt) {
|
|
|
626
626
|
*
|
|
627
627
|
*/
|
|
628
628
|
exports.ampRoutes = (app, opts = {}) => {
|
|
629
|
-
const { ampStoryPageHandler, storyPageInfiniteScrollHandler
|
|
629
|
+
const { ampStoryPageHandler, storyPageInfiniteScrollHandler } = require("./amp/handlers");
|
|
630
630
|
|
|
631
631
|
getWithConfig(app, "/amp/story/*", ampStoryPageHandler, opts);
|
|
632
632
|
getWithConfig(app, "/amp/api/v1/amp-infinite-scroll", storyPageInfiniteScrollHandler, opts);
|
|
633
|
-
getWithConfig(app, "/amp/api/v1/bookend.json", bookendHandler, opts);
|
|
634
633
|
getWithConfig(app, "/ampstories/*", ampStoryPageHandler, { ...opts, isVisualStory: true });
|
|
635
634
|
};
|
|
@@ -446,41 +446,3 @@ describe("Amp infinite scroll handler", () => {
|
|
|
446
446
|
});
|
|
447
447
|
});
|
|
448
448
|
});
|
|
449
|
-
|
|
450
|
-
describe("Amp visual stories bookend handler", () => {
|
|
451
|
-
it("returns the bookend if there are related stories", function (done) {
|
|
452
|
-
const app = createApp({
|
|
453
|
-
clientStub: getClientStubWithRelatedStories([{ headline: "foo" }]),
|
|
454
|
-
});
|
|
455
|
-
supertest(app)
|
|
456
|
-
.get("/amp/api/v1/bookend.json?storyId=111§ionId=222")
|
|
457
|
-
.expect("Content-Type", /json/)
|
|
458
|
-
.expect("Cache-Control", /public/)
|
|
459
|
-
.expect(200)
|
|
460
|
-
.then((res) => {
|
|
461
|
-
const response = JSON.parse(res.text);
|
|
462
|
-
assert.equal("v1.0", response.bookendVersion);
|
|
463
|
-
assert.equal(3, response.components.length);
|
|
464
|
-
assert.equal("foo", response.components[1].title);
|
|
465
|
-
})
|
|
466
|
-
.then(() => done());
|
|
467
|
-
});
|
|
468
|
-
it("returns a 404 if there are no related stories", (done) => {
|
|
469
|
-
const app = createApp({ clientStub: getClientStubWithRelatedStories([]) });
|
|
470
|
-
supertest(app)
|
|
471
|
-
.get("/amp/api/v1/bookend.json?storyId=111§ionId=222")
|
|
472
|
-
.expect("Content-Type", /json/)
|
|
473
|
-
.expect(404)
|
|
474
|
-
.then(() => done());
|
|
475
|
-
});
|
|
476
|
-
it("returns a 400 if 'storyId' and 'sectionId' query params aren't passed", (done) => {
|
|
477
|
-
const app = createApp({
|
|
478
|
-
clientStub: getClientStubWithRelatedStories([{ headline: "foo" }]),
|
|
479
|
-
});
|
|
480
|
-
supertest(app)
|
|
481
|
-
.get("/amp/api/v1/bookend.json")
|
|
482
|
-
.expect("Content-Type", /json/)
|
|
483
|
-
.expect(400)
|
|
484
|
-
.then(() => done());
|
|
485
|
-
});
|
|
486
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const get = require("lodash/get");
|
|
2
|
-
|
|
3
|
-
function getStoryUrl(story, config) {
|
|
4
|
-
if (get(story, ["story-template"]) === "news-elsewhere") {
|
|
5
|
-
return get(story, ["metadata", "reference-url"], "");
|
|
6
|
-
}
|
|
7
|
-
return `${config["sketches-host"]}/${story.slug}`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function bookendHandler(req, res, next, { config, client, sMaxAge = "900" }) {
|
|
11
|
-
const { storyId, sectionId } = req.query;
|
|
12
|
-
if (!storyId || !sectionId) {
|
|
13
|
-
res.status(400).json({
|
|
14
|
-
error: {
|
|
15
|
-
message: "Please provide 'storyId' and 'sectionId' query parameters",
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const relatedStoriesResponse = await client.getRelatedStories(storyId, sectionId);
|
|
22
|
-
const relatedStories = relatedStoriesResponse["related-stories"];
|
|
23
|
-
|
|
24
|
-
if (!relatedStories.length) {
|
|
25
|
-
res.status(404).json({ error: { message: "Not Found" } });
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const fbAppId = get(config, ["public-integrations", "facebook", "app-id"], "");
|
|
30
|
-
|
|
31
|
-
const jsonPayLoad = {
|
|
32
|
-
bookendVersion: "v1.0",
|
|
33
|
-
shareProviders: [
|
|
34
|
-
"twitter",
|
|
35
|
-
"email",
|
|
36
|
-
{
|
|
37
|
-
provider: "facebook",
|
|
38
|
-
app_id: fbAppId,
|
|
39
|
-
},
|
|
40
|
-
"whatsapp",
|
|
41
|
-
"linkedin",
|
|
42
|
-
"gplus",
|
|
43
|
-
],
|
|
44
|
-
components: [].concat(
|
|
45
|
-
[
|
|
46
|
-
{
|
|
47
|
-
type: "heading",
|
|
48
|
-
text: "More to read",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
relatedStories.map((story) => ({
|
|
52
|
-
type: "small",
|
|
53
|
-
title: `${story.headline}`,
|
|
54
|
-
image: `${config["cdn-name"]}${story["hero-image-s3-key"]}?w=480&auto=format&compress`,
|
|
55
|
-
url: getStoryUrl(story, config),
|
|
56
|
-
})),
|
|
57
|
-
[
|
|
58
|
-
{
|
|
59
|
-
type: "cta-link",
|
|
60
|
-
links: [
|
|
61
|
-
{
|
|
62
|
-
text: "More stories",
|
|
63
|
-
url: `${config["sketches-host"]}`,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
]
|
|
68
|
-
),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
res.header("Cache-Control", `public,max-age=15,s-maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=14400`);
|
|
72
|
-
res.header("Vary", "Accept-Encoding");
|
|
73
|
-
|
|
74
|
-
res.json(jsonPayLoad);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = { bookendHandler };
|