In both smallgroup.controller.js and classyear.controller.js the following four functions are identical:
handleError
validationError
generateCode
uniqueDayCode
We should abstract these four functions into a separate file and import them as needed.
Let's abstract them into a file called observatory-server/server/api/lib/helpers.js - use the following code as an example of how to import the functions into both controller files:
import { handleError, validationError, generateCode, uniqueDayCode } from '../lib/helpers'
In both
smallgroup.controller.js
andclassyear.controller.js
the following four functions are identical:handleError
validationError
generateCode
uniqueDayCode
We should abstract these four functions into a separate file and import them as needed.
Let's abstract them into a file called
observatory-server/server/api/lib/helpers.js
- use the following code as an example of how to import the functions into both controller files: