# Pastebin kP5o2wvs var express = require('express'); var util = require('util'); function ControllerList () { this.controllers = {}; function add (name, controller) { return this.controllers[`${name}Controller`] = controller; } } var app = express(); var list = new ControllerList(); // ControllerList is a class so we create new class instance list.add('Users', function() { return { getUserById: function(){}, editUserById: function(){}, deleteUserById: function(){}, // ... }; }); list.add('Purchase', function () { return { getAllPurchases: function () {}, getPurchaseById: function() {}, editPurchaseById: function() {}, // ... } }); var router = express.Router(); router.get('/', function () { // Home Router, not Home Controller // Router functions are used for managing URLs (/, /settings, /about, /profile) list.controllers.UserController.getUserById(100).then(function (userData) { res.send('do something with userData'); }); }); router.get('/purchases', function (req, res) { list.controllers.PurchaseController.getAllPurchases().then(function (purchases) { res.send('do something with all purchases'); }); }); app.use(router); // Start server app.listen(8000);