File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ aircrashRouter.use(authorize(airCrashViewers));
3434
3535aircrashRouter . get (
3636 '/' ,
37- [ query ( 'page' ) . default ( 0 ) . isInt ( ) , query ( 'limit ' ) . default ( 10 ) . isInt ( { gt : 0 } ) ] ,
37+ [ query ( 'page' ) . default ( 0 ) . isInt ( ) , query ( 'perPage ' ) . default ( 10 ) . isInt ( { gt : 0 } ) ] ,
3838 ReturnValidationErrors ,
3939 async ( req : Request , res : Response ) => {
4040 try {
@@ -55,7 +55,7 @@ aircrashRouter.get(
5555 } = req . query ;
5656
5757 const page = parseInt ( req . query . page ?. toString ( ) || '' ) || 1 ;
58- const perPage = parseInt ( req . query . limit ?. toString ( ) || '' ) || 10 ;
58+ const perPage = parseInt ( req . query . perPage ?. toString ( ) || '' ) || 10 ;
5959
6060 const data = await aircrashService . doSearch ( page , perPage , {
6161 textToMatch,
Original file line number Diff line number Diff line change @@ -47,7 +47,12 @@ export class AircrashService {
4747
4848 // _TODO_ move into base-controller.ts
4949 const MAX_PER_PAGE = 1000 ;
50- const limit = Math . max ( 1 , Math . min ( perPage , MAX_PER_PAGE ) ) ;
50+ let limit = 0 ;
51+ if ( perPage === - 1 ) {
52+ limit = MAX_PER_PAGE ;
53+ } else {
54+ limit = Math . max ( 1 , Math . min ( perPage , MAX_PER_PAGE ) ) ;
55+ }
5156 const offset = ( page - 1 ) * limit ;
5257
5358 const aircrashes = await db
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { api } from './config';
33export default {
44 async get (
55 page ,
6- limit ,
6+ perPage ,
77 textToMatch ,
88 sortBy ,
99 sort ,
@@ -23,7 +23,7 @@ export default {
2323 crossdomain : true ,
2424 params : {
2525 page,
26- limit ,
26+ perPage ,
2727 textToMatch,
2828 sortBy,
2929 sort,
You can’t perform that action at this time.
0 commit comments