(req: Request)
| 8 | } |
| 9 | |
| 10 | export const getPageAndLimitParams = (req: Request): Pagination => { |
| 11 | // by default assume no pagination |
| 12 | let page = -1 |
| 13 | let limit = -1 |
| 14 | if (req.query.page) { |
| 15 | // if page is provided, make sure it's a positive number |
| 16 | page = parseInt(req.query.page as string) |
| 17 | if (page < 0) { |
| 18 | throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: page cannot be negative!`) |
| 19 | } |
| 20 | } |
| 21 | if (req.query.limit) { |
| 22 | // if limit is provided, make sure it's a positive number |
| 23 | limit = parseInt(req.query.limit as string) |
| 24 | if (limit < 0) { |
| 25 | throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: limit cannot be negative!`) |
| 26 | } |
| 27 | } |
| 28 | return { page, limit } |
| 29 | } |
no outgoing calls
no test coverage detected