@quintype/framework 7.3.1 → 7.3.2-term-connection-on-config.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
package/server/routes.js
CHANGED
|
@@ -25,6 +25,7 @@ const cdnProviderFunc = () => "akamai";
|
|
|
25
25
|
|
|
26
26
|
function createApp(loadData, routes, opts = {}, app = express()) {
|
|
27
27
|
const { redirectToLowercaseSlugs = false } = opts;
|
|
28
|
+
const emptyFunc = () => {};
|
|
28
29
|
isomorphicRoutes(
|
|
29
30
|
app,
|
|
30
31
|
Object.assign(
|
|
@@ -33,9 +34,10 @@ function createApp(loadData, routes, opts = {}, app = express()) {
|
|
|
33
34
|
assetHash: (file) => (file === "app.js" ? "abcdef" : null),
|
|
34
35
|
assetPath: (file) => `/assets/${file}`,
|
|
35
36
|
},
|
|
36
|
-
getClient: getClientStub,
|
|
37
|
+
getClient: opts.getClientStub || getClientStub,
|
|
37
38
|
generateRoutes: () => routes,
|
|
38
39
|
loadData,
|
|
40
|
+
logError: opts.logError || emptyFunc,
|
|
39
41
|
pickComponent: opts.pickComponent || pickComponent,
|
|
40
42
|
renderLayout: (res, { store, title, content }) =>
|
|
41
43
|
res.send(JSON.stringify({ store: store.getState(), title, content })),
|
|
@@ -51,6 +53,33 @@ function createApp(loadData, routes, opts = {}, app = express()) {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
describe("Isomorphic Handler", function () {
|
|
56
|
+
it("Renders a 404 when a publisher is not found", function (done) {
|
|
57
|
+
const app = createApp(
|
|
58
|
+
(pageType, params, config, client, { host }) => Promise.resolve({ pageType, data: { text: "foobar", host } }),
|
|
59
|
+
[{ pageType: "home-page", path: "/", exact: true }],
|
|
60
|
+
{
|
|
61
|
+
getClientStub: (hostname) => {
|
|
62
|
+
return {
|
|
63
|
+
getHostname: () => "demo.quintype.io",
|
|
64
|
+
getConfig: () => Promise.reject("Pubisher not found"),
|
|
65
|
+
baseUrl: "https://www.foo.com",
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
logError: (error) => {
|
|
69
|
+
console.log(error);
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
supertest(app)
|
|
75
|
+
.get("/")
|
|
76
|
+
.expect(500)
|
|
77
|
+
.then((res) => {
|
|
78
|
+
assert.equal("An internal error occured for this publisher's config", res.text);
|
|
79
|
+
})
|
|
80
|
+
.then(done);
|
|
81
|
+
});
|
|
82
|
+
|
|
54
83
|
it("Renders the page if the route matches", function (done) {
|
|
55
84
|
const app = createApp(
|
|
56
85
|
(pageType, params, config, client, { host }) =>
|