-import { query } from 'express-validator/check'
-import { isValidLogLevel } from '../../helpers/custom-validators/logs'
+import { areValidationErrors } from './shared'
+
+const createClientLogValidator = [
+ body('message')
+ .custom(isValidClientLogMessage),
+
+ body('url')
+ .custom(isUrlValid),
+
+ body('level')
+ .custom(isValidClientLogLevel),
+
+ body('stackTrace')
+ .optional()
+ .custom(isValidClientLogStackTrace),
+
+ body('meta')
+ .optional()
+ .custom(isValidClientLogMeta),
+
+ body('userAgent')
+ .optional()
+ .custom(isValidClientLogUserAgent),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (CONFIG.LOG.ACCEPT_CLIENT_LOG !== true) {
+ return res.sendStatus(HttpStatusCode.FORBIDDEN_403)
+ }
+
+ if (areValidationErrors(req, res)) return
+
+ return next()
+ }
+]