I have expressjs application with straitfort route processing like the following:
app.route('/').get(function(req, res, next) {
// handling code;
});
app.route('/account').get(function(req, res, next) {
// handling code;
});
app.route('/profile').get(function(req, res, next) {
// handling code;
});
At now I put all my code inside route handler but I want try to delegate it to some class such as the following.
app.route('/').get(function(req, res, next) {
new IndexPageController().get(req, res, next);
});
app.route('/account').get(function(req, res, next) {
new AccountPageController().get(req, res, next);
});
app.route('/profile').get(function(req, res, next) {
new ProfilePageController().get(req, res, next);
});
So what do you thing about the approach above and meybe you know the better one?