Refactored getAll into regular GET. I.e. /db/achievement

This commit is contained in:
Ruben Vereecken 2014-05-20 00:05:21 +02:00
parent df60402d00
commit 0f1c59f2d5
2 changed files with 2 additions and 3 deletions

View file

@ -11,7 +11,7 @@ class AchievementHandler extends Handler
hasAccess: (req) -> hasAccess: (req) ->
req.method is 'GET' or req.user?.isAdmin() req.method is 'GET' or req.user?.isAdmin()
getAll: (req, res) -> get: (req, res) ->
query = @modelClass.find({}) query = @modelClass.find({})
query.exec (err, documents) => query.exec (err, documents) =>
return @sendDatabaseError(res, err) if err return @sendDatabaseError(res, err) if err

View file

@ -37,7 +37,6 @@ module.exports.setup = (app) ->
return handler.search(req, res) if req.route.method is 'get' and parts[1] is 'search' return handler.search(req, res) if req.route.method is 'get' and parts[1] is 'search'
return handler.getNamesByIDs(req, res) if req.route.method in ['get', 'post'] and parts[1] is 'names' return handler.getNamesByIDs(req, res) if req.route.method in ['get', 'post'] and parts[1] is 'names'
return handler.getByRelationship(req, res, parts[1..]...) if parts.length > 2 return handler.getByRelationship(req, res, parts[1..]...) if parts.length > 2
return handler.getAll(req, res) if req.route.method is 'get' and parts[1] is 'all'
return handler.getById(req, res, parts[1]) if req.route.method is 'get' and parts[1]? return handler.getById(req, res, parts[1]) if req.route.method is 'get' and parts[1]?
return handler.patch(req, res, parts[1]) if req.route.method is 'patch' and parts[1]? return handler.patch(req, res, parts[1]) if req.route.method is 'patch' and parts[1]?
handler[req.route.method](req, res) handler[req.route.method](req, res)