1 import express from 'express'
2 import { query } from 'express-validator'
3 import { isStringArray } from '@server/helpers/custom-validators/search'
4 import { isValidLogLevel } from '../../helpers/custom-validators/logs'
5 import { isDateValid, toArray } from '../../helpers/custom-validators/misc'
6 import { logger } from '../../helpers/logger'
7 import { areValidationErrors } from './shared'
9 const getLogsValidator = [
11 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
14 .custom(isValidLogLevel).withMessage('Should have a valid level'),
17 .customSanitizer(toArray)
18 .custom(isStringArray).withMessage('Should have a valid one of tags array'),
21 .custom(isDateValid).withMessage('Should have an end date that conforms to ISO 8601'),
23 (req: express.Request, res: express.Response, next: express.NextFunction) => {
24 logger.debug('Checking getLogsValidator parameters.', { parameters: req.query })
26 if (areValidationErrors(req, res)) return
32 const getAuditLogsValidator = [
34 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
37 .custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
39 (req: express.Request, res: express.Response, next: express.NextFunction) => {
40 logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query })
42 if (areValidationErrors(req, res)) return
48 // ---------------------------------------------------------------------------