From 566c125d6eee3bd907404523d94e1e0b5e403a46 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Dec 2019 14:14:01 +0100 Subject: Serve audit logs to client --- server/middlewares/validators/logs.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts index 07f3f552f..70e4d0d99 100644 --- a/server/middlewares/validators/logs.ts +++ b/server/middlewares/validators/logs.ts @@ -24,8 +24,25 @@ const getLogsValidator = [ } ] +const getAuditLogsValidator = [ + query('startDate') + .custom(isDateValid).withMessage('Should have a valid start date'), + query('endDate') + .optional() + .custom(isDateValid).withMessage('Should have a valid end date'), + + (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query }) + + if (areValidationErrors(req, res)) return + + return next() + } +] + // --------------------------------------------------------------------------- export { - getLogsValidator + getLogsValidator, + getAuditLogsValidator } -- cgit v1.2.3