@@ -132,7 +132,7 @@ const
132132 * @apiUse ContentTypeJSON
133133 *
134134 */
135- const updateBox = async function updateBox ( req , res , next ) {
135+ const updateBox = async function updateBox ( req , res ) {
136136 try {
137137 let box = await Box . findBoxById ( req . _userParams . boxId , { lean : false , populate : false } ) ;
138138 box = await box . updateBox ( req . _userParams ) ;
@@ -143,7 +143,7 @@ const updateBox = async function updateBox (req, res, next) {
143143 res . send ( { code : 'Ok' , data : box . toJSON ( { includeSecrets : true } ) } ) ;
144144 clearCache ( [ 'getBoxes' ] ) ;
145145 } catch ( err ) {
146- handleError ( err , next ) ;
146+ return handleError ( err ) ;
147147 }
148148} ;
149149
@@ -167,12 +167,12 @@ const updateBox = async function updateBox (req, res, next) {
167167 * { "coordinates": [7.68323, 51.9423], "type": "Point", "timestamp": "2017-07-27T12:02:00Z"}
168168 * ]
169169 */
170- const getBoxLocations = async function getBoxLocations ( req , res , next ) {
170+ const getBoxLocations = async function getBoxLocations ( req , res ) {
171171 try {
172172 const box = await Box . findBoxById ( req . _userParams . boxId , { onlyLocations : true , lean : false } ) ;
173173 res . send ( await box . getLocations ( req . _userParams ) ) ;
174174 } catch ( err ) {
175- handleError ( err , next ) ;
175+ return handleError ( err ) ;
176176 }
177177} ;
178178
@@ -211,7 +211,7 @@ const geoJsonStringifyReplacer = function geoJsonStringifyReplacer (key, box) {
211211 * @apiSampleRequest https://api.opensensemap.org/boxes?date=2015-03-07T02:50Z&phenomenon=Temperatur
212212 * @apiSampleRequest https://api.opensensemap.org/boxes?date=2015-03-07T02:50Z,2015-04-07T02:50Z&phenomenon=Temperatur
213213 */
214- const getBoxes = async function getBoxes ( req , res , next ) {
214+ const getBoxes = async function getBoxes ( req , res ) {
215215 // content-type is always application/json for this route
216216 res . header ( 'Content-Type' , 'application/json; charset=utf-8' ) ;
217217
@@ -252,7 +252,7 @@ const getBoxes = async function getBoxes (req, res, next) {
252252 } )
253253 . pipe ( res ) ;
254254 } catch ( err ) {
255- handleError ( err , next ) ;
255+ return handleError ( err ) ;
256256 }
257257} ;
258258
@@ -357,7 +357,7 @@ const getBoxes = async function getBoxes (req, res, next) {
357357}
358358 */
359359
360- const getBox = async function getBox ( req , res , next ) {
360+ const getBox = async function getBox ( req , res ) {
361361 const { format, boxId } = req . _userParams ;
362362
363363 try {
@@ -372,7 +372,7 @@ const getBox = async function getBox (req, res, next) {
372372 }
373373 res . send ( box ) ;
374374 } catch ( err ) {
375- handleError ( err , next ) ;
375+ return handleError ( err ) ;
376376 }
377377} ;
378378
@@ -406,7 +406,7 @@ const getBox = async function getBox (req, res, next) {
406406 * @apiUse ContentTypeJSON
407407 * @apiUse JWTokenAuth
408408 */
409- const postNewBox = async function postNewBox ( req , res , next ) {
409+ const postNewBox = async function postNewBox ( req , res ) {
410410 try {
411411 let newBox = await req . user . addBox ( req . _userParams ) ;
412412 newBox = await Box . populate ( newBox , Box . BOX_SUB_PROPS_FOR_POPULATION ) ;
@@ -422,7 +422,7 @@ const postNewBox = async function postNewBox (req, res, next) {
422422 } ](https://opensensemap.org/explore/${ newBox . _id } )`
423423 ) ;
424424 } catch ( err ) {
425- handleError ( err , next ) ;
425+ return handleError ( err ) ;
426426 }
427427} ;
428428
@@ -443,7 +443,7 @@ const postNewBox = async function postNewBox (req, res, next) {
443443 * @apiUse JWTokenAuth
444444 * @apiUse BoxIdParam
445445 */
446- const getSketch = async function getSketch ( req , res , next ) {
446+ const getSketch = async function getSketch ( req , res ) {
447447 res . header ( 'Content-Type' , 'text/plain; charset=utf-8' ) ;
448448 try {
449449 const box = await Box . findBoxById ( req . _userParams . boxId , { populate : false , lean : false } ) ;
@@ -468,7 +468,7 @@ const getSketch = async function getSketch (req, res, next) {
468468
469469 res . send ( box . getSketch ( params ) ) ;
470470 } catch ( err ) {
471- handleError ( err , next ) ;
471+ return handleError ( err ) ;
472472 }
473473} ;
474474
@@ -482,7 +482,7 @@ const getSketch = async function getSketch (req, res, next) {
482482 * @apiUse JWTokenAuth
483483 * @apiUse BoxIdParam
484484 */
485- const deleteBox = async function deleteBox ( req , res , next ) {
485+ const deleteBox = async function deleteBox ( req , res ) {
486486 const { password, boxId } = req . _userParams ;
487487
488488 try {
@@ -493,7 +493,7 @@ const deleteBox = async function deleteBox (req, res, next) {
493493 postToMattermost ( `Box deleted: ${ req . user . name } (${ redactEmail ( req . user . email ) } ) just deleted "${ box . name } " (${ boxId } )` ) ;
494494
495495 } catch ( err ) {
496- handleError ( err , next ) ;
496+ return handleError ( err ) ;
497497 }
498498} ;
499499
@@ -505,15 +505,15 @@ const deleteBox = async function deleteBox (req, res, next) {
505505 * @apiUse JWTokenAuth
506506 * @apiUse BoxIdParam
507507 */
508- const getTransfer = async function getTransfer ( req , res , next ) {
508+ const getTransfer = async function getTransfer ( req , res ) {
509509 const { boxId } = req . _userParams ;
510510 try {
511511 const transfer = await Claim . findClaimByDeviceID ( boxId ) ;
512512 res . send ( 200 , {
513513 data : transfer ,
514514 } ) ;
515515 } catch ( err ) {
516- handleError ( err , next ) ;
516+ return handleError ( err ) ;
517517 }
518518} ;
519519
@@ -526,7 +526,7 @@ const getTransfer = async function getTransfer (req, res, next) {
526526 * @apiParam (RequestBody) {RFC3339Date} expiresAt Expiration date for transfer token (default: 24 hours from now).
527527 * @apiUse JWTokenAuth
528528 */
529- const createTransfer = async function createTransfer ( req , res , next ) {
529+ const createTransfer = async function createTransfer ( req , res ) {
530530 const { boxId, date } = req . _userParams ;
531531 try {
532532 const transferCode = await req . user . transferBox ( boxId , date ) ;
@@ -535,7 +535,7 @@ const createTransfer = async function createTransfer (req, res, next) {
535535 data : transferCode ,
536536 } ) ;
537537 } catch ( err ) {
538- handleError ( err , next ) ;
538+ return handleError ( err ) ;
539539 }
540540} ;
541541
@@ -549,7 +549,7 @@ const createTransfer = async function createTransfer (req, res, next) {
549549 * @apiUse JWTokenAuth
550550 * @apiUse BoxIdParam
551551 */
552- const updateTransfer = async function updateTransfer ( req , res , next ) {
552+ const updateTransfer = async function updateTransfer ( req , res ) {
553553 const { boxId, token, date } = req . _userParams ;
554554 try {
555555 const transfer = await req . user . updateTransfer ( boxId , token , date ) ;
@@ -558,7 +558,7 @@ const updateTransfer = async function updateTransfer (req, res, next) {
558558 data : transfer ,
559559 } ) ;
560560 } catch ( err ) {
561- handleError ( err , next ) ;
561+ return handleError ( err ) ;
562562 }
563563} ;
564564
@@ -571,13 +571,13 @@ const updateTransfer = async function updateTransfer (req, res, next) {
571571 * @apiParam (RequestBody) {String} token Transfer token you want to revoke.
572572 * @apiUse JWTokenAuth
573573 */
574- const removeTransfer = async function removeTransfer ( req , res , next ) {
574+ const removeTransfer = async function removeTransfer ( req , res ) {
575575 const { boxId, token } = req . _userParams ;
576576 try {
577577 await req . user . removeTransfer ( boxId , token ) ;
578578 res . send ( 204 ) ;
579579 } catch ( err ) {
580- handleError ( err , next ) ;
580+ return handleError ( err ) ;
581581 }
582582} ;
583583
@@ -590,7 +590,7 @@ const removeTransfer = async function removeTransfer (req, res, next) {
590590 * @apiParam (RequestBody) {String} token the token to claim a senseBox
591591 * @apiUse JWTokenAuth
592592 */
593- const claimBox = async function claimBox ( req , res , next ) {
593+ const claimBox = async function claimBox ( req , res ) {
594594 const { token } = req . _userParams ;
595595
596596 try {
@@ -601,7 +601,7 @@ const claimBox = async function claimBox (req, res, next) {
601601
602602 res . send ( 200 , { message : 'Device successfully claimed!' } ) ;
603603 } catch ( err ) {
604- handleError ( err , next ) ;
604+ return handleError ( err ) ;
605605 }
606606} ;
607607
0 commit comments