@quintype/framework 7.3.2-node16.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.3.2-node16.1",
3
+ "version": "7.3.2-term-connection-on-config.0",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -38,7 +38,7 @@
38
38
  "compression": "^1.7.4",
39
39
  "ejs": "^3.1.6",
40
40
  "express": "^4.17.1",
41
- "firebase": "^9.6.10",
41
+ "firebase": "^6.0.2",
42
42
  "get-youtube-id": "^1.0.1",
43
43
  "grpc": "^1.21.1",
44
44
  "http-proxy": "^1.18.1",
package/server/routes.js CHANGED
@@ -168,7 +168,10 @@ function withConfigPartial(
168
168
  })
169
169
  )
170
170
  )
171
- .catch(logError);
171
+ .catch((e) => {
172
+ logError(e);
173
+ res.status(500).send("An internal error occured for this publisher's config");
174
+ });
172
175
  };
173
176
  };
174
177
  }
@@ -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 }) =>