@@ -42,7 +42,6 @@ module.exports = {
4242 * @apiSuccess {Integer} versions.maintainer_id Id of the maintainer of the package version
4343 * @apiSuccess {String} type Always 'package'
4444 */
45-
4645 findByName : function ( req , res ) {
4746 var packageName = req . param ( 'name' ) ;
4847
@@ -85,8 +84,10 @@ module.exports = {
8584 * @api {get } /packages List all packages
8685 * @apiName Get Packages
8786 * @apiGroup Package
88- * @apiDescription Return an array of package object containing listed attributes
87+ * @apiDescription Return an array of package object containing listed attributes and total number of package objects header.
8988 *
89+ * @apiHeader (Header) {String} x-total-count total count of packages.
90+ *
9091 * @apiParam {String} limit the number to use when limiting records to send back (useful for pagination)
9192 * @apiParam {String} skip the number of records to skip when limiting (useful for pagination)
9293 * @apiParam {String} sort the order of returned records, e.g. `name ASC` or `name DESC`
@@ -106,15 +107,16 @@ module.exports = {
106107 var limit = Utils . parseLimit ( req ) ;
107108 var offset = Utils . parseSkip ( req ) ;
108109 var sort = Utils . parseSort ( req ) ;
109- var criteria = Utils . parseCriteria ( req ) ;
110+ var criteria = Utils . parseCriteria ( req ) ;
110111
111112 Package . findAll ( {
112- where : criteria ,
113113 limit : limit ,
114+ where : criteria ,
114115 offset : offset ,
115116 order : sort ,
116117 include : [ ]
117118 } ) . then ( function ( packages ) {
119+ res . set ( 'X-Total-Count' , packages . length ) ;
118120 return res . json ( packages ) ;
119121 } ) . catch ( function ( err ) {
120122 return res . negotiate ( err ) ;
0 commit comments