@quintype/framework 7.34.7-handle-500-issue.0 → 7.34.7-handle-500-issue.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.34.7-handle-500-issue.0",
3
+ "version": "7.34.7-handle-500-issue.1",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -486,9 +486,11 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute(
486
486
  return res.redirect(301, result.data.location);
487
487
  }
488
488
 
489
- if (statusCode == 500) {
490
- console.log("RESULT 111 =============>>>", statusCode);
491
- return res.sendStatus(500);
489
+ // For server errors (>=500),send statuss
490
+ if (statusCode >= 500) {
491
+ res.status(statusCode);
492
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
493
+ return res.sendStatus(statusCode);
492
494
  }
493
495
 
494
496
  const seoInstance = getSeoInstance(seo, config, result.pageType);
@@ -154,31 +154,22 @@ describe("Isomorphic Handler", function () {
154
154
  .then(done);
155
155
  });
156
156
 
157
- // it("Throws a 500 if loadData doesn't work", function (done) {
158
- // const app = createApp(
159
- // (pageType, params, config, client) => {
160
- // throw "exception";
161
- // },
162
- // [{ pageType: "home-page", path: "/" }],
163
- // {
164
- // loadErrorData: (err, config) => ({
165
- // httpStatusCode: err.httpStatusCode || 500,
166
- // pageType: "not-found",
167
- // data: { text: "foobar" },
168
- // }),
169
- // }
170
- // );
171
- // supertest(app)
172
- // .get("/")
173
- // .expect("Content-Type", /html/)
174
- // .expect(500)
175
- // .then((res) => {
176
- // const response = JSON.parse(res.text);
177
- // assert.equal('<div data-page-type="not-found">foobar</div>', response.content);
178
- // assert.equal(true, response.store.qt.disableIsomorphicComponent);
179
- // })
180
- // .then(done, done);
181
- // });
157
+ it("Throws a 500 if loadData doesn't work", function (done) {
158
+ const app = createApp(
159
+ (pageType, params, config, client) => {
160
+ throw "exception";
161
+ },
162
+ [{ pageType: "home-page", path: "/" }],
163
+ {
164
+ loadErrorData: (err, config) => ({
165
+ httpStatusCode: err.httpStatusCode || 500,
166
+ pageType: "not-found",
167
+ data: { text: "foobar" },
168
+ }),
169
+ }
170
+ );
171
+ supertest(app).get("/").expect(500, done);
172
+ });
182
173
 
183
174
  it("Throws a 500 if loadData and loadErrorData both crash", function (done) {
184
175
  const app = createApp(
@@ -193,7 +184,7 @@ describe("Isomorphic Handler", function () {
193
184
  }
194
185
  );
195
186
 
196
- supertest(app).get("/").expect("Content-Type", /html/).expect(500, done);
187
+ supertest(app).get("/").expect(500, done);
197
188
  });
198
189
 
199
190
  it("Cache headers are set", function (done) {