feat: granular endpoints for rundown

This commit is contained in:
Carlos Valente
2024-07-10 13:23:37 +02:00
committed by Carlos Valente
parent e6c3322321
commit 917b182e39
8 changed files with 143 additions and 18 deletions
@@ -1,4 +1,4 @@
import { body, param, validationResult } from 'express-validator';
import { body, param, query, validationResult } from 'express-validator';
import { Request, Response, NextFunction } from 'express';
export const rundownPostValidator = [
@@ -75,3 +75,14 @@ export const rundownArrayOfIds = [
next();
},
];
export const rundownGetPaginatedQueryParams = [
query('offset').isNumeric().optional(),
query('limit').isNumeric().optional(),
(req: Request, res: Response, next: NextFunction) => {
const errors = validationResult(req);
if (!errors.isEmpty()) return res.status(422).json({ errors: errors.array() });
next();
},
];