Closed aeksco closed 6 years ago
Clean up tasks:
Replace all var statements with either let or const.
var
let
const
Replace per-file definitions of handleError with the one defined in api/lib/helpers.js:
handleError
api/lib/helpers.js
import { handleError } from '../lib/helpers'
Make whitespace consistent in file (i.e. if(err){ ... should be if (err) { ...)
if(err){ ...
if (err) { ...
Replace " (double quote) with ' (single quotes) for string constants
"
'
Replace function keyword with => function syntax, i.e.: this:
function
=>
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) ... })
ClassYear.find({}) .then((model) => { ... }) .catch((err) => { handleError(err) })
Clean up tasks:
Replace all
var
statements with eitherlet
orconst
.Replace per-file definitions of
handleError
with the one defined inapi/lib/helpers.js
:Make whitespace consistent in file (i.e.
if(err){ ...
should beif (err) { ...
)Replace
"
(double quote) with'
(single quotes) for string constantsReplace
function
keyword with=>
function syntax, i.e.: this:becomes:
Replace Mongoose callbacks with promises:
this:
becomes: