hello all, I'm relatively new to nodejs and am in the process of building my first nodejs app using expressjs.I'm wondering what the benefit (if any) to using classes to define controller's and their methods.what would the difference be between creating a UserController which is called in the route as soconst userController = new UserController();router.get('/', userController.getAll);as opposed to have userController be a file with various exported functions?import userController from './controllers/userController.js';router.get('/', userController.getAll);both of these should work without a problem, as in the second example userController is only an object which contains various functions.But in terms of scale-ability and future-proofing code for new ES releases, what is the difference between these two styles or it just that, a style choice with no real difference in how we can scale our apps.
Submitted January 11, 2019 at 02:14PM by Dasnowman1183
No comments:
Post a Comment