express-ext 0.2.3 → 0.2.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.
@@ -1,22 +1,32 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- var GenericController_1 = require("./GenericController");
17
- var http_1 = require("./http");
18
- var search_1 = require("./search");
19
- var search_func_1 = require("./search_func");
1
+ 'use strict';
2
+ var __extends =
3
+ (this && this.__extends) ||
4
+ (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics =
7
+ Object.setPrototypeOf ||
8
+ ({ __proto__: [] } instanceof Array &&
9
+ function (d, b) {
10
+ d.__proto__ = b;
11
+ }) ||
12
+ function (d, b) {
13
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14
+ };
15
+ return extendStatics(d, b);
16
+ };
17
+ return function (d, b) {
18
+ extendStatics(d, b);
19
+ function __() {
20
+ this.constructor = d;
21
+ }
22
+ d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
23
+ };
24
+ })();
25
+ Object.defineProperty(exports, '__esModule', { value: true });
26
+ var GenericController_1 = require('./GenericController');
27
+ var http_1 = require('./http');
28
+ var search_1 = require('./search');
29
+ var search_func_1 = require('./search_func');
20
30
  var GenericSearchController = (function (_super) {
21
31
  __extends(GenericSearchController, _super);
22
32
  function GenericSearchController(log, find, service, config, build, validate, dates, numbers) {
@@ -44,10 +54,14 @@ var GenericSearchController = (function (_super) {
44
54
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
45
55
  var l = search_1.getParameters(s, this.config);
46
56
  var s2 = search_1.format(s, this.dates, this.numbers);
47
- this.find(s2, l.limit, l.skipOrRefId, l.fields)
48
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
49
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
57
+ this.find(s2, l.limit, l.offsetOrNextPageToken, l.fields)
58
+ .then(function (result) {
59
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
60
+ })
61
+ .catch(function (err) {
62
+ return http_1.handleError(err, res, _this.log);
63
+ });
50
64
  };
51
65
  return GenericSearchController;
52
- }(GenericController_1.GenericController));
66
+ })(GenericController_1.GenericController);
53
67
  exports.GenericSearchController = GenericSearchController;
@@ -1,22 +1,32 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- var http_1 = require("./http");
17
- var LoadController_1 = require("./LoadController");
18
- var search_1 = require("./search");
19
- var search_func_1 = require("./search_func");
1
+ 'use strict';
2
+ var __extends =
3
+ (this && this.__extends) ||
4
+ (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics =
7
+ Object.setPrototypeOf ||
8
+ ({ __proto__: [] } instanceof Array &&
9
+ function (d, b) {
10
+ d.__proto__ = b;
11
+ }) ||
12
+ function (d, b) {
13
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14
+ };
15
+ return extendStatics(d, b);
16
+ };
17
+ return function (d, b) {
18
+ extendStatics(d, b);
19
+ function __() {
20
+ this.constructor = d;
21
+ }
22
+ d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
23
+ };
24
+ })();
25
+ Object.defineProperty(exports, '__esModule', { value: true });
26
+ var http_1 = require('./http');
27
+ var LoadController_1 = require('./LoadController');
28
+ var search_1 = require('./search');
29
+ var search_func_1 = require('./search_func');
20
30
  function useSearchController(log, find, viewService, array, dates, numbers, keys, config) {
21
31
  var c = new LoadSearchController(log, find, viewService, keys, config, dates, numbers);
22
32
  c.array = array;
@@ -35,8 +45,7 @@ var LoadSearchController = (function (_super) {
35
45
  if (config) {
36
46
  if (typeof config === 'boolean') {
37
47
  _this.csv = config;
38
- }
39
- else {
48
+ } else {
40
49
  _this.config = search_1.initializeConfig(config);
41
50
  if (_this.config) {
42
51
  _this.csv = _this.config.csv;
@@ -60,12 +69,16 @@ var LoadSearchController = (function (_super) {
60
69
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
61
70
  var l = search_1.getParameters(s, this.config);
62
71
  var s2 = search_1.format(s, this.dates, this.numbers);
63
- this.find(s2, l.limit, l.skipOrRefId, l.fields)
64
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
65
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
72
+ this.find(s2, l.limit, l.offsetOrNextPageToken, l.fields)
73
+ .then(function (result) {
74
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
75
+ })
76
+ .catch(function (err) {
77
+ return http_1.handleError(err, res, _this.log);
78
+ });
66
79
  };
67
80
  return LoadSearchController;
68
- }(LoadController_1.LoadController));
81
+ })(LoadController_1.LoadController);
69
82
  exports.LoadSearchController = LoadSearchController;
70
83
  var QueryController = (function (_super) {
71
84
  __extends(QueryController, _super);
@@ -77,8 +90,7 @@ var QueryController = (function (_super) {
77
90
  if (config) {
78
91
  if (typeof config === 'boolean') {
79
92
  _this.csv = config;
80
- }
81
- else {
93
+ } else {
82
94
  _this.config = search_1.initializeConfig(config);
83
95
  if (_this.config) {
84
96
  _this.csv = _this.config.csv;
@@ -102,11 +114,16 @@ var QueryController = (function (_super) {
102
114
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
103
115
  var l = search_1.getParameters(s, this.config);
104
116
  var s2 = search_1.format(s, this.dates, this.numbers);
105
- this.query.search(s2, l.limit, l.skipOrRefId, l.fields)
106
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
107
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
117
+ this.query
118
+ .search(s2, l.limit, l.offsetOrNextPageToken, l.fields)
119
+ .then(function (result) {
120
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
121
+ })
122
+ .catch(function (err) {
123
+ return http_1.handleError(err, res, _this.log);
124
+ });
108
125
  };
109
126
  return QueryController;
110
- }(LoadController_1.LoadController));
127
+ })(LoadController_1.LoadController);
111
128
  exports.QueryController = QueryController;
112
129
  exports.QueryHandler = QueryController;
@@ -1,22 +1,32 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- var GenericController_1 = require("./GenericController");
17
- var http_1 = require("./http");
18
- var search_1 = require("./search");
19
- var search_func_1 = require("./search_func");
1
+ 'use strict';
2
+ var __extends =
3
+ (this && this.__extends) ||
4
+ (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics =
7
+ Object.setPrototypeOf ||
8
+ ({ __proto__: [] } instanceof Array &&
9
+ function (d, b) {
10
+ d.__proto__ = b;
11
+ }) ||
12
+ function (d, b) {
13
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14
+ };
15
+ return extendStatics(d, b);
16
+ };
17
+ return function (d, b) {
18
+ extendStatics(d, b);
19
+ function __() {
20
+ this.constructor = d;
21
+ }
22
+ d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
23
+ };
24
+ })();
25
+ Object.defineProperty(exports, '__esModule', { value: true });
26
+ var GenericController_1 = require('./GenericController');
27
+ var http_1 = require('./http');
28
+ var search_1 = require('./search');
29
+ var search_func_1 = require('./search_func');
20
30
  var LowcodeController = (function (_super) {
21
31
  __extends(LowcodeController, _super);
22
32
  function LowcodeController(log, lowCodeService, config, build, validate, dates, numbers) {
@@ -44,12 +54,17 @@ var LowcodeController = (function (_super) {
44
54
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
45
55
  var l = search_1.getParameters(s, this.config);
46
56
  var s2 = search_1.format(s, this.dates, this.numbers);
47
- this.lowCodeService.search(s2, l.limit, l.skipOrRefId, l.fields)
48
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
49
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
57
+ this.lowCodeService
58
+ .search(s2, l.limit, l.offsetOrNextPageToken, l.fields)
59
+ .then(function (result) {
60
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
61
+ })
62
+ .catch(function (err) {
63
+ return http_1.handleError(err, res, _this.log);
64
+ });
50
65
  };
51
66
  return LowcodeController;
52
- }(GenericController_1.GenericController));
67
+ })(GenericController_1.GenericController);
53
68
  exports.LowcodeController = LowcodeController;
54
69
  exports.LowcodeHandler = LowcodeController;
55
70
  var Controller = (function (_super) {
@@ -79,10 +94,15 @@ var Controller = (function (_super) {
79
94
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
80
95
  var l = search_1.getParameters(s, this.config);
81
96
  var s2 = search_1.format(s, this.dates, this.numbers);
82
- this.lowCodeService.search(s2, l.limit, l.skipOrRefId, l.fields)
83
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
84
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
97
+ this.lowCodeService
98
+ .search(s2, l.limit, l.offsetOrNextPageToken, l.fields)
99
+ .then(function (result) {
100
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
101
+ })
102
+ .catch(function (err) {
103
+ return http_1.handleError(err, res, _this.log);
104
+ });
85
105
  };
86
106
  return Controller;
87
- }(GenericController_1.GenericController));
107
+ })(GenericController_1.GenericController);
88
108
  exports.Controller = Controller;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var http_1 = require("./http");
4
- var search_1 = require("./search");
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ var http_1 = require('./http');
4
+ var search_1 = require('./search');
5
5
  var SearchController = (function () {
6
6
  function SearchController(log, find, config, dates, numbers) {
7
7
  this.log = log;
@@ -12,8 +12,7 @@ var SearchController = (function () {
12
12
  if (config) {
13
13
  if (typeof config === 'boolean') {
14
14
  this.csv = config;
15
- }
16
- else {
15
+ } else {
17
16
  this.config = search_1.initializeConfig(config);
18
17
  if (this.config) {
19
18
  this.csv = this.config.csv;
@@ -31,10 +30,14 @@ var SearchController = (function () {
31
30
  var s = search_1.fromRequest(req, search_1.buildArray(this.array, this.fields, this.excluding));
32
31
  var l = search_1.getParameters(s, this.config);
33
32
  var s2 = search_1.format(s, this.dates, this.numbers);
34
- this.find(s2, l.limit, l.skipOrRefId, l.fields)
35
- .then(function (result) { return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config); })
36
- .catch(function (err) { return http_1.handleError(err, res, _this.log); });
33
+ this.find(s2, l.limit, l.offsetOrNextPageToken, l.fields)
34
+ .then(function (result) {
35
+ return search_1.jsonResult(res, result, _this.csv, l.fields, _this.config);
36
+ })
37
+ .catch(function (err) {
38
+ return http_1.handleError(err, res, _this.log);
39
+ });
37
40
  };
38
41
  return SearchController;
39
- }());
42
+ })();
40
43
  exports.SearchController = SearchController;
package/lib/http.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
3
  Object.defineProperty(Error.prototype, 'toJSON', {
4
4
  value: function () {
5
5
  var alt = {};
@@ -9,14 +9,13 @@ Object.defineProperty(Error.prototype, 'toJSON', {
9
9
  return alt;
10
10
  },
11
11
  configurable: true,
12
- writable: true
12
+ writable: true,
13
13
  });
14
14
  function handleError(err, res, log) {
15
15
  if (log) {
16
16
  log(toString(err));
17
17
  res.status(500).end('Internal Server Error');
18
- }
19
- else {
18
+ } else {
20
19
  res.status(500).end(toString(err));
21
20
  }
22
21
  }
@@ -25,8 +24,7 @@ exports.error = handleError;
25
24
  function toString(v) {
26
25
  if (typeof v === 'string') {
27
26
  return v;
28
- }
29
- else {
27
+ } else {
30
28
  return JSON.stringify(v);
31
29
  }
32
30
  }
@@ -48,8 +46,7 @@ exports.attrs = attrs;
48
46
  function respondModel(obj, res) {
49
47
  if (obj) {
50
48
  res.status(200).json(obj).end();
51
- }
52
- else {
49
+ } else {
53
50
  res.status(404).json(null).end();
54
51
  }
55
52
  }
@@ -91,14 +88,12 @@ function queryParam(req, res, name) {
91
88
  if (!v) {
92
89
  res.status(400).end("'" + name + "' cannot be empty");
93
90
  return undefined;
94
- }
95
- else {
91
+ } else {
96
92
  var v1 = v.toString();
97
93
  if (v1.length === 0) {
98
94
  res.status(400).end("'" + name + "' cannot be empty");
99
95
  return undefined;
100
- }
101
- else {
96
+ } else {
102
97
  return v1;
103
98
  }
104
99
  }
@@ -287,8 +282,7 @@ function minimize(obj) {
287
282
  var v = obj[key];
288
283
  if (v == null) {
289
284
  delete obj[key];
290
- }
291
- else if (Array.isArray(v) && v.length > 0) {
285
+ } else if (Array.isArray(v) && v.length > 0) {
292
286
  var v1 = v[0];
293
287
  if (typeof v1 === o && !(v1 instanceof Date)) {
294
288
  for (var _a = 0, v_1 = v; _a < v_1.length; _a++) {