abler-api 0.1.2 → 0.1.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.
@@ -992,6 +992,50 @@ class apiUtil$1 {
992
992
 
993
993
  static tokenDataExist(token) {
994
994
  return kvStorage.stored(token);
995
+ }
996
+
997
+ static parametersOK(params) {
998
+ configNeeded();
999
+ let paramSufix = params._param_sufix || "";
1000
+
1001
+ for (let i = 1; i < arguments.length; i++) {
1002
+ let paramName = arguments[i];
1003
+ let paramExists = false;
1004
+
1005
+ if (paramName.includes("/")) {
1006
+ let names = paramName.split("/"); // if (params[names[0]]) {
1007
+ // paramExists = true;
1008
+ // } else {
1009
+ // if (params[names[1]]) {
1010
+ // paramExists = true;
1011
+ // params[names[0]] = params[names[1]];
1012
+ // delete params[names[1]];
1013
+ // }
1014
+ // }
1015
+
1016
+ for (let ind in names) {
1017
+ let name = names[ind];
1018
+
1019
+ if (typeof params[name] != 'undefined') {
1020
+ paramExists = true;
1021
+ break;
1022
+ }
1023
+
1024
+ if (paramSufix != "" && typeof params[name + paramSufix] != 'undefined') {
1025
+ paramExists = true;
1026
+ break;
1027
+ }
1028
+ }
1029
+
1030
+ paramName = `${paramName} 之一`;
1031
+ } else {
1032
+ paramExists = typeof params[paramName] != 'undefined' || typeof params[paramName + paramSufix] != 'undefined';
1033
+ }
1034
+
1035
+ if (!paramExists) return ppUtil$1.errorPormise(err.ERROR(err.PARAMETER_NEEDED, paramName));
1036
+ }
1037
+
1038
+ return Promise.resolve(paramSufix);
995
1039
  } //#endregion
996
1040
  //region ====中间件
997
1041
 
@@ -984,6 +984,50 @@ class apiUtil$1 {
984
984
 
985
985
  static tokenDataExist(token) {
986
986
  return kvStorage.stored(token);
987
+ }
988
+
989
+ static parametersOK(params) {
990
+ configNeeded();
991
+ let paramSufix = params._param_sufix || "";
992
+
993
+ for (let i = 1; i < arguments.length; i++) {
994
+ let paramName = arguments[i];
995
+ let paramExists = false;
996
+
997
+ if (paramName.includes("/")) {
998
+ let names = paramName.split("/"); // if (params[names[0]]) {
999
+ // paramExists = true;
1000
+ // } else {
1001
+ // if (params[names[1]]) {
1002
+ // paramExists = true;
1003
+ // params[names[0]] = params[names[1]];
1004
+ // delete params[names[1]];
1005
+ // }
1006
+ // }
1007
+
1008
+ for (let ind in names) {
1009
+ let name = names[ind];
1010
+
1011
+ if (typeof params[name] != 'undefined') {
1012
+ paramExists = true;
1013
+ break;
1014
+ }
1015
+
1016
+ if (paramSufix != "" && typeof params[name + paramSufix] != 'undefined') {
1017
+ paramExists = true;
1018
+ break;
1019
+ }
1020
+ }
1021
+
1022
+ paramName = `${paramName} 之一`;
1023
+ } else {
1024
+ paramExists = typeof params[paramName] != 'undefined' || typeof params[paramName + paramSufix] != 'undefined';
1025
+ }
1026
+
1027
+ if (!paramExists) return ppUtil$1.errorPormise(err.ERROR(err.PARAMETER_NEEDED, paramName));
1028
+ }
1029
+
1030
+ return Promise.resolve(paramSufix);
987
1031
  } //#endregion
988
1032
  //region ====中间件
989
1033
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.2",
3
+ "version": "0.1.7",
4
4
  "description": "API服务相关工具",
5
5
  "main": "./dist/cjs/pp-util.js",
6
6
  "module": "./dist/es/pp-util.js",