@nka212bg/backend-utils 0.1.37 → 0.1.39

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 (2) hide show
  1. package/db/dbUtils.js +6 -8
  2. package/package.json +1 -1
package/db/dbUtils.js CHANGED
@@ -19,17 +19,15 @@ exports.paramsSanitize = (params) => {
19
19
  if (!Array.isArray(params)) params = [params];
20
20
 
21
21
  return params.map((param) => {
22
- if (typeof param == "object" && param !== null) {
23
- return JSON.stringify(param);
24
- }
22
+ if (typeof param == "object" && param !== null) return JSON.stringify(param);
23
+ if (typeof param == "boolean") return param ? 1 : 0;
24
+ if (typeof param == "number") return param;
25
25
 
26
26
  param = String(param).trim();
27
- const pLowerCase = param.toLowerCase();
27
+ if (param !== "" && !isNaN(param)) return Number(param);
28
28
 
29
- if (pLowerCase === "true") return 1;
30
- if (pLowerCase === "false") return 0;
31
- if (!param || pLowerCase == "null" || pLowerCase == "undefined") return undefined;
32
- // if (!isNaN(param)) return Number(param);
29
+ const pLowerCase = param.toLowerCase();
30
+ if (pLowerCase === "null" || pLowerCase === "undefined") return undefined;
33
31
 
34
32
  return param;
35
33
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nka212bg/backend-utils",
3
3
  "author": "nka212bg",
4
- "version": "0.1.37",
4
+ "version": "0.1.39",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@maxmind/geoip2-node": "^5.0.0",