@nka212bg/backend-utils 0.1.36 → 0.1.38

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.
package/db/dbUtils.js CHANGED
@@ -19,17 +19,13 @@ 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
27
  const pLowerCase = param.toLowerCase();
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);
28
+ if (pLowerCase === "null" || pLowerCase === "undefined") return undefined;
33
29
 
34
30
  return param;
35
31
  });
package/misc.js CHANGED
@@ -152,8 +152,9 @@ exports.fileServe = ({ filePath, res, download, img } = {}) => {
152
152
  };
153
153
 
154
154
  exports.incomingForm = (req) => {
155
+ if (!req.is("multipart/form-data")) return ["", req.body, ""];
156
+
155
157
  return new Promise((resolve) => {
156
- if (!req.is("multipart/form-data")) return resolve(["", req.body, ""]);
157
158
  new IncomingForm().parse(req, (err, fields, files) => resolve([err, fields, files]));
158
159
  });
159
160
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nka212bg/backend-utils",
3
3
  "author": "nka212bg",
4
- "version": "0.1.36",
4
+ "version": "0.1.38",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@maxmind/geoip2-node": "^5.0.0",