Adding routes and a controller to the application

We will edit the app.js file to add routes to the band-list.html view and also their respective controller:

  1. Open app.js and add the following lines after the index controller import:
          // Inject band controller 
          var bands = require('./controllers/band'); 
          // Inject user controller 
          var users = require('./controllers/user'); 
    
  2. Add the following code after the index route app.get('/', index.show);:
     // Defining route to list and post app.get('/bands', bands.list); // Get band by ID app.get('/band/:id', bands.byId); // Create band app.post('/bands', bands.create); // Update app.put('/band/:id', bands.update); // Delete by id app.delete('/band/:id', bands.delete); // Defining route to list and post users app.get('/users', ...

Get Node.js 6.x Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.