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.
Create a file called
books.js
inside thecontrollers
folder.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 pictures list router.get('/books', function...