This commit is contained in:
David Arranz 2019-08-26 17:42:52 +02:00
parent f926efda9a
commit e080548da9
5 changed files with 6 additions and 7 deletions

View File

@ -84,13 +84,13 @@ function setPaginationInfo(totalCount, res) {
limit = (params.paginate && params.paginate.limit) ? params.paginate.limit : null, limit = (params.paginate && params.paginate.limit) ? params.paginate.limit : null,
count = (limit) ? Math.ceil(totalCount / limit) : null; count = (limit) ? Math.ceil(totalCount / limit) : null;
if (params.paginate.hasNextPages(count)) { /*if (params.paginate.hasNextPages(count)) {
const nextPage = params.paginate.href(); const nextPage = params.paginate.href();
res.set('Link-Next-Page', nextPage + '; rel=next'); res.set('Link-Next-Page', nextPage + '; rel=next');
res.set('Pagination-Next-Page', true); res.set('Pagination-Next-Page', true);
} else { } else {
res.set('Pagination-Next-Page', false); res.set('Pagination-Next-Page', false);
} }*/
res.set({ res.set({
'Pagination-Count': count, 'Pagination-Count': count,
@ -131,7 +131,6 @@ function handleErrorResponse(controllerName, methodName, error, res) {
} }
function handleResultResponse(result, totalCount = null, params, res, statusCode = httpStatus.OK) { function handleResultResponse(result, totalCount = null, params, res, statusCode = httpStatus.OK) {
console.log('handleResultResponse(result>>>>>>>>>>>>>>', result, getTotalCount(result));
setPaginationInfo((totalCount) ? totalCount : getTotalCount(result), res); setPaginationInfo((totalCount) ? totalCount : getTotalCount(result), res);
res.status(statusCode).send(typeof result == 'number' ? result.toString() : result); res.status(statusCode).send(typeof result == 'number' ? result.toString() : result);
} }

View File

@ -18,7 +18,7 @@ const extraMethods = {
rows = rows.map(comment => commentComposer(comment, context)); rows = rows.map(comment => commentComposer(comment, context));
return { return {
count: rows.length, count: result.count,
rows: rows rows: rows
} }
}, },

View File

@ -19,7 +19,7 @@ const extraMethods = {
rows = rows.map(entity => entityComposer(entity, context)); rows = rows.map(entity => entityComposer(entity, context));
return { return {
count: rows.length, count: result.count,
rows: rows rows: rows
} }
}, },

View File

@ -24,7 +24,7 @@ const extraMethods = {
rows = rows.map(event => eventComposer(event, context)); rows = rows.map(event => eventComposer(event, context));
return { return {
count: rows.length, count: result.count,
rows: rows rows: rows
} }

View File

@ -63,7 +63,7 @@
"response-time": "^2.3.2", "response-time": "^2.3.2",
"safename": "^1.0.2", "safename": "^1.0.2",
"sanitize-filename": "^1.6.2", "sanitize-filename": "^1.6.2",
"sequelize": "^5.6.1", "sequelize": "^5.16.0",
"sharp": "^0.23.0", "sharp": "^0.23.0",
"unique-file-name": "^1.0.0", "unique-file-name": "^1.0.0",
"vimeo": "^2.1.1", "vimeo": "^2.1.1",