Improve Code Quality in achievement.controller.js
Closed this issue · 1 comments
aeksco commented
Clean up tasks:
-
Replace all
var
statements with eitherlet
orconst
. -
Replace per-file definitions of
handleError
with the one defined inapi/lib/helpers.js
:
import { handleError } from '../lib/helpers'
-
Make whitespace consistent in file (i.e.
if(err){ ...
should beif (err) { ...
) -
Replace
"
(double quote) with'
(single quotes) for string constants -
Replace
function
keyword with=>
function syntax, i.e.:
this:
ClassYear.findOne({"dayCodes.code":code})
.exec(function(err, classYear){
...
})
becomes:
ClassYear.findOne({"dayCodes.code":code})
.exec((err, classYear) => {
...
})
- Replace Mongoose callbacks with promises:
this:
ClassYear.find({}, function (err, model) {
if (err) return handleError(err)
...
})
becomes:
ClassYear.find({})
.then((model) => {
...
})
.catch((err) => {
handleError(err)
})
aeksco commented
Resolved