@napp/dti-server 3.0.2 → 3.0.7

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.
Files changed (3) hide show
  1. package/adapter.d.ts +1 -0
  2. package/adapter.js +20 -11
  3. package/package.json +2 -2
package/adapter.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare class ServerInstance<RES, PQ, PB> {
27
27
  get path(): string;
28
28
  get queryMode(): string;
29
29
  get bodyMode(): string;
30
+ check(q: PQ, b: PB): void;
30
31
  before(funcs: Array<IMiddleware>): this;
31
32
  handle(action: IAction<RES, PQ, PB>): this;
32
33
  }
package/adapter.js CHANGED
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
- to[j] = from[i];
5
- return to;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
6
10
  };
7
11
  Object.defineProperty(exports, "__esModule", { value: true });
8
12
  exports.ServerAdapter = exports.ServerInstance = void 0;
@@ -46,6 +50,10 @@ var ServerInstance = /** @class */ (function () {
46
50
  enumerable: false,
47
51
  configurable: true
48
52
  });
53
+ ServerInstance.prototype.check = function (q, b) {
54
+ this.meta.checkQ(q);
55
+ this.meta.checkB(b);
56
+ };
49
57
  ServerInstance.prototype.before = function (funcs) {
50
58
  this.beforeFuncs = funcs;
51
59
  return this;
@@ -96,6 +104,7 @@ var ServerAdapter = /** @class */ (function () {
96
104
  if (it.actionFunc) {
97
105
  var q = this.qParam(it, req);
98
106
  var b = req.body;
107
+ it.check(q || {}, b || {});
99
108
  return it.actionFunc({ q: q, b: b }, { req: req, res: res })
100
109
  .then(function (rsu) {
101
110
  if (rsu instanceof response_1.DtiResponse) {
@@ -125,23 +134,23 @@ var ServerAdapter = /** @class */ (function () {
125
134
  var _loop_1 = function (it) {
126
135
  var befores = it.beforeFuncs || [];
127
136
  if (it.method === 'get') {
128
- _route.get(it.path, __spreadArray(__spreadArray([], befores), [function (req, res, next) {
137
+ _route.get(it.path, __spreadArray(__spreadArray([], befores, true), [function (req, res, next) {
129
138
  _this.callAction(it, req, res, next);
130
- }]));
139
+ }], false));
131
140
  }
132
141
  else if (it.method === 'post') {
133
142
  var bodyparser = this_1.getBodyParser(it);
134
143
  if (bodyparser.length === 0) {
135
- this_1.logger('warn', "not found body parser. name=\"" + it.name + "\"; bodyMode=\"" + it.bodyMode + "\"");
144
+ this_1.logger('warn', "not found body parser. name=\"".concat(it.name, "\"; bodyMode=\"").concat(it.bodyMode, "\""));
136
145
  }
137
- _route.post(it.path, __spreadArray(__spreadArray(__spreadArray([], bodyparser), befores), [function (req, res, next) {
146
+ _route.post(it.path, __spreadArray(__spreadArray(__spreadArray([], bodyparser, true), befores, true), [function (req, res, next) {
138
147
  _this.callAction(it, req, res, next);
139
- }]));
148
+ }], false));
140
149
  }
141
150
  else {
142
- this_1.logger('warn', "not supored method. \"" + it.method + "\"");
151
+ this_1.logger('warn', "not supored method. \"".concat(it.method, "\""));
143
152
  }
144
- this_1.logger('info', "[" + it.method + "] " + it.path);
153
+ this_1.logger('info', "[".concat(it.method, "] ").concat(it.path));
145
154
  };
146
155
  var this_1 = this;
147
156
  for (var _i = 0, _a = this.actions; _i < _a.length; _i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napp/dti-server",
3
- "version": "3.0.2",
3
+ "version": "3.0.7",
4
4
  "description": "data transaction interface server library",
5
5
  "types": "index.d.ts",
6
6
  "main": "index.js",
@@ -12,6 +12,6 @@
12
12
  "author": "Farcek <farcek@gmail.com>",
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
- "@napp/dti-core": "3.0.2"
15
+ "@napp/dti-core": "3.0.7"
16
16
  }
17
17
  }