diff --git a/server/resources/mailResource.ts b/server/resources/mailResource.ts index 8c48ce7..20069a5 100644 --- a/server/resources/mailResource.ts +++ b/server/resources/mailResource.ts @@ -3,8 +3,8 @@ import ErrorTypes from "../utils/errorTypes"; import * as MailService from "../services/mailService"; import * as Resources from "../utils/resources"; import {handleJSONWithData, RequestData} from "../utils/resources"; -import {normalizeString, parseInteger} from "../utils/strings"; -import {forConstraint} from "../validation/validator"; +import {normalizeString, parseInteger} from "../shared/utils/strings"; +import {forConstraint} from "../shared/validation/validator"; import {Request, Response} from "express"; import {isString, Mail, MailId} from "../types"; diff --git a/server/resources/monitoringResource.ts b/server/resources/monitoringResource.ts index 38f7573..e4c34df 100644 --- a/server/resources/monitoringResource.ts +++ b/server/resources/monitoringResource.ts @@ -3,8 +3,8 @@ import ErrorTypes from "../utils/errorTypes"; import * as MonitoringService from "../services/monitoringService"; import * as Resources from "../utils/resources"; import {handleJSONWithData} from "../utils/resources"; -import {normalizeString} from "../utils/strings"; -import {forConstraint} from "../validation/validator"; +import {normalizeString} from "../shared/utils/strings"; +import {forConstraint} from "../shared/validation/validator"; import {Request, Response} from "express"; import {isMonitoringToken, JSONObject, MonitoringResponse, MonitoringToken, toMonitoringResponse} from "../types"; diff --git a/server/resources/nodeResource.ts b/server/resources/nodeResource.ts index 69de0b1..0df379a 100644 --- a/server/resources/nodeResource.ts +++ b/server/resources/nodeResource.ts @@ -2,8 +2,8 @@ import Constraints from "../shared/validation/constraints"; import ErrorTypes from "../utils/errorTypes"; import * as MonitoringService from "../services/monitoringService"; import * as NodeService from "../services/nodeService"; -import {normalizeMac, normalizeString} from "../utils/strings"; -import {forConstraint, forConstraints} from "../validation/validator"; +import {normalizeMac, normalizeString} from "../shared/utils/strings"; +import {forConstraint, forConstraints} from "../shared/validation/validator"; import * as Resources from "../utils/resources"; import {handleJSONWithData} from "../utils/resources"; import {Request, Response} from "express"; diff --git a/server/resources/taskResource.ts b/server/resources/taskResource.ts index e983f38..079d2db 100644 --- a/server/resources/taskResource.ts +++ b/server/resources/taskResource.ts @@ -3,8 +3,8 @@ import ErrorTypes from "../utils/errorTypes"; import * as Resources from "../utils/resources"; import {handleJSONWithData, RequestData} from "../utils/resources"; import {getTasks, Task, TaskState} from "../jobs/scheduler"; -import {normalizeString} from "../utils/strings"; -import {forConstraint} from "../validation/validator"; +import {normalizeString} from "../shared/utils/strings"; +import {forConstraint} from "../shared/validation/validator"; import {Request, Response} from "express"; import {isString, isTaskSortField} from "../types"; diff --git a/server/services/monitoringService.ts b/server/services/monitoringService.ts index 1c00f04..dd99f6b 100644 --- a/server/services/monitoringService.ts +++ b/server/services/monitoringService.ts @@ -11,10 +11,10 @@ import * as MailService from "../services/mailService"; import * as NodeService from "../services/nodeService"; import * as Resources from "../utils/resources"; import {RestParams} from "../utils/resources"; -import {normalizeMac, parseInteger} from "../utils/strings"; +import {normalizeMac, parseInteger} from "../shared/utils/strings"; import {monitoringDisableUrl} from "../utils/urlBuilder"; import CONSTRAINTS from "../shared/validation/constraints"; -import {forConstraint} from "../validation/validator"; +import {forConstraint} from "../shared/validation/validator"; import { Domain, DurationSeconds, diff --git a/server/services/nodeService.ts b/server/services/nodeService.ts index 8347640..ee83f6c 100644 --- a/server/services/nodeService.ts +++ b/server/services/nodeService.ts @@ -8,7 +8,7 @@ import ErrorTypes from "../utils/errorTypes"; import Logger from "../logger"; import logger from "../logger"; import * as MailService from "../services/mailService"; -import {normalizeString} from "../utils/strings"; +import {normalizeString} from "../shared/utils/strings"; import {monitoringConfirmUrl, monitoringDisableUrl} from "../utils/urlBuilder"; import { BaseNode, diff --git a/server/utils/strings.ts b/server/shared/utils/strings.ts similarity index 91% rename from server/utils/strings.ts rename to server/shared/utils/strings.ts index b19f155..f41bf9f 100644 --- a/server/utils/strings.ts +++ b/server/shared/utils/strings.ts @@ -1,4 +1,3 @@ -import _ from "lodash" import {isString, MAC} from "../types"; export function normalizeString(str: string): string { @@ -19,7 +18,7 @@ export function normalizeMac(mac: MAC): MAC { } export function parseInteger(str: string): number { - const parsed = _.parseInt(str, 10); + const parsed = parseInt(str, 10); if (parsed.toString() === str) { return parsed; } else { diff --git a/server/validation/validator.ts b/server/shared/validation/validator.ts similarity index 94% rename from server/validation/validator.ts rename to server/shared/validation/validator.ts index a771acf..43983e3 100644 --- a/server/validation/validator.ts +++ b/server/shared/validation/validator.ts @@ -1,5 +1,4 @@ import {parseInteger} from "../utils/strings"; -import Logger from "../logger"; import {isBoolean, isNumber, isObject, isOptional, isRegExp, isString, toIsArray} from "../types"; export interface Constraint { @@ -117,7 +116,6 @@ function isValid(constraint: Constraint, acceptUndefined: boolean, value: unknow return isValidString(constraint, value); } - Logger.tag('validation').error('No validation method for constraint type: {}', constraint.type); return false; } @@ -131,7 +129,6 @@ function areValid(constraints: Constraints, acceptUndefined: boolean, values: Va for (const field of Object.keys(values)) { if (!fields.has(field)) { - Logger.tag('validation').error('Validation failed: No constraint for field: {}', field); return false; } } diff --git a/server/utils/resources.ts b/server/utils/resources.ts index fe8b85d..cfeb065 100644 --- a/server/utils/resources.ts +++ b/server/utils/resources.ts @@ -3,7 +3,7 @@ import _ from "lodash"; import CONSTRAINTS from "../shared/validation/constraints"; import ErrorTypes from "../utils/errorTypes"; import Logger from "../logger"; -import {Constraints, forConstraints, isConstraints} from "../validation/validator"; +import {Constraints, forConstraints, isConstraints} from "../shared/validation/validator"; import {Request, Response} from "express"; import { EnumTypeGuard,