axe-api 1.5.0-rc-11 → 1.5.0-rc-12

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = (err, req, res, next) => {
4
4
  // Sett the HTTP status code
5
5
  res.statusCode = 500;
6
+ console.log(err);
6
7
  // Set the default HTTP message
7
8
  res.write(JSON.stringify({
8
9
  error: "Internal server error",
@@ -15,7 +15,7 @@ exports.default = (context) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  // Adding cache tags
16
16
  const { primaryKey } = model.instance;
17
17
  const config = model.getCacheConfiguration(handlerType);
18
- context.req.original.tags.push(...result.data.map((i) => (0, Helpers_1.toCacheTagKey)(model, i[primaryKey], config)));
18
+ context.req.original.tags.push(...((result === null || result === void 0 ? void 0 : result.data) || result || []).map((i) => (0, Helpers_1.toCacheTagKey)(model, i[primaryKey], config)));
19
19
  // Caching the results
20
20
  yield (0, Helpers_1.putCache)(context, result);
21
21
  res.json(result);
@@ -11,9 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const Helpers_1 = require("../../Handlers/Helpers");
13
13
  exports.default = (context) => __awaiter(void 0, void 0, void 0, function* () {
14
- var _a;
15
- // Serializing the data by the model's serialize method
16
- context.result.data = yield (0, Helpers_1.serializeData)(context.version, ((_a = context.result) === null || _a === void 0 ? void 0 : _a.data) || context.result || [], context.model.serialize, context.handlerType, context.req);
17
- // Filtering hidden fields from the response data.
18
- (0, Helpers_1.filterHiddenFields)(context.result.data, context.model.instance.hiddens);
14
+ var _a, _b;
15
+ const { version, model, handlerType, req } = context;
16
+ if ((_a = context.result) === null || _a === void 0 ? void 0 : _a.data) {
17
+ // Serializing the data by the model's serialize method
18
+ context.result.data = yield (0, Helpers_1.serializeData)(version, ((_b = context.result) === null || _b === void 0 ? void 0 : _b.data) || [], model.serialize, handlerType, req);
19
+ // Filtering hidden fields from the response data.
20
+ (0, Helpers_1.filterHiddenFields)(context.result.data, context.model.instance.hiddens);
21
+ }
22
+ else if (context.result && Array.isArray(context.result)) {
23
+ context.result = yield (0, Helpers_1.serializeData)(version, context.result || [], model.serialize, handlerType, req);
24
+ // Filtering hidden fields from the response data.
25
+ (0, Helpers_1.filterHiddenFields)(context.result, context.model.instance.hiddens);
26
+ }
19
27
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axe-api",
3
- "version": "1.5.0-rc-11",
3
+ "version": "1.5.0-rc-12",
4
4
  "description": "AXE API is a simple tool to create Rest APIs quickly.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",