Creating the book controller

We will follow the same generator code pattern that the generator suggests; one of the advantages of using this generator is that we already have the MVC pattern at our disposal.

Tip

Remember, you can download the example files from the Packpub website, or directly from the GitHub book repository.

  1. Create a file called books.js inside the controllers folder.
  2. Add the following code to the book.js file:
     var express = require('express'), router = express.Router(), schema = require('../models/book'), Picture = schema.models.Picture, cloudinary = require('cloudinary').v2, fs = require('fs'), multipart = require('connect-multiparty'), multipartMiddleware = multipart(); module.exports = function (app) { app.use('/', router); }; ...

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.