Move the count of results for the pagination in constants module

pull/10/head
Chocobozzz 2016-05-13 20:10:02 +02:00
parent fbf1134e3e
commit 3fe81fa75e
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,9 @@ let FRIEND_BASE_SCORE = 100
// Time to wait between requests to the friends // Time to wait between requests to the friends
let INTERVAL = 60000 let INTERVAL = 60000
// Number of results by default for the pagination
const PAGINATION_COUNT_DEFAULT = 15
// Number of points we add/remove from a friend after a successful/bad request // Number of points we add/remove from a friend after a successful/bad request
const PODS_SCORE = { const PODS_SCORE = {
MALUS: -10, MALUS: -10,
@ -37,6 +40,7 @@ module.exports = {
API_VERSION: API_VERSION, API_VERSION: API_VERSION,
FRIEND_BASE_SCORE: FRIEND_BASE_SCORE, FRIEND_BASE_SCORE: FRIEND_BASE_SCORE,
INTERVAL: INTERVAL, INTERVAL: INTERVAL,
PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
PODS_SCORE: PODS_SCORE, PODS_SCORE: PODS_SCORE,
REQUEST_RETRIES: REQUEST_RETRIES, REQUEST_RETRIES: REQUEST_RETRIES,
THUMBNAILS_SIZE: THUMBNAILS_SIZE, THUMBNAILS_SIZE: THUMBNAILS_SIZE,

View File

@ -1,5 +1,7 @@
'use strict' 'use strict'
const constants = require('../initializers/constants')
const paginationMiddleware = { const paginationMiddleware = {
setPagination: setPagination setPagination: setPagination
} }
@ -7,7 +9,7 @@ const paginationMiddleware = {
function setPagination (req, res, next) { function setPagination (req, res, next) {
if (!req.query.start) req.query.start = 0 if (!req.query.start) req.query.start = 0
else req.query.start = parseInt(req.query.start) else req.query.start = parseInt(req.query.start)
if (!req.query.count) req.query.count = 15 if (!req.query.count) req.query.count = constants.PAGINATION_COUNT_DEFAULT
else req.query.count = parseInt(req.query.count) else req.query.count = parseInt(req.query.count)
return next() return next()