badmfck-api-server 2.9.9 → 3.0.0

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.
@@ -89,7 +89,7 @@ async function Initializer(services) {
89
89
  exports.Initializer = Initializer;
90
90
  class APIService extends BaseService_1.BaseService {
91
91
  static nextLogID = 0;
92
- version = "2.9.9";
92
+ version = "3.0.0";
93
93
  options;
94
94
  monitor = null;
95
95
  monitorIndexFile;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Validator = exports.ValidationReport = void 0;
7
+ const dns_1 = __importDefault(require("dns"));
4
8
  var ValidationReport;
5
9
  (function (ValidationReport) {
6
10
  ValidationReport[ValidationReport["OK"] = 1] = "OK";
@@ -63,6 +67,24 @@ class Validator {
63
67
  errors.push("wrong value for field '" + i + "', expected " + expected.join(", ") + " got: " + value);
64
68
  }
65
69
  }
70
+ if (typeof structure[i] === "string" && structure[i].includes("regex:")) {
71
+ const regex = structure[i].substring(6);
72
+ const reg = new RegExp(regex);
73
+ if (reg.test(object[i]) === false)
74
+ errors.push("wrong value for field '" + i + "', false mask for: " + object[i]);
75
+ }
76
+ if (typeof structure[i] === "string" && (structure[i] === "@" || structure[i] === "email")) {
77
+ const value = object[i].toString().toLowerCase().trim();
78
+ if (value.replaceAll(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/g, "").length !== 0)
79
+ errors.push("wrong value for field '" + i + "', expected email got: " + object[i]);
80
+ const domain = value.split("@")[1];
81
+ try {
82
+ await dns_1.default.promises.resolveMx(domain);
83
+ }
84
+ catch (e) {
85
+ return ["MX Domain is incorrect"];
86
+ }
87
+ }
66
88
  if (typeof structure[i] === "number") {
67
89
  if (isNaN(object[i]))
68
90
  errors.push("wrong value for field '" + i + "', expected number got " + object[i]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.9.9",
3
+ "version": "3.0.0",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",