1 import * as express from 'express'
2 import { query } from 'express-validator'
3 import { isValidLogLevel } from '../../helpers/custom-validators/logs'
4 import { isDateValid } from '../../helpers/custom-validators/misc'
5 import { logger } from '../../helpers/logger'
6 import { areValidationErrors } from './shared'
8 const getLogsValidator = [
10 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
13 .custom(isValidLogLevel).withMessage('Should have a valid level'),
16 .custom(isDateValid).withMessage('Should have an end date that conforms to ISO 8601'),
18 (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking getLogsValidator parameters.', { parameters: req.query })
21 if (areValidationErrors(req, res)) return
27 const getAuditLogsValidator = [
29 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
32 .custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
34 (req: express.Request, res: express.Response, next: express.NextFunction) => {
35 logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query })
37 if (areValidationErrors(req, res)) return
43 // ---------------------------------------------------------------------------