Book Image

Web Development with MongoDB and Node.js

By : Jason Krol
Book Image

Web Development with MongoDB and Node.js

By: Jason Krol

Overview of this book

This book is designed for developers of any skill level that want to get up and running using Node.js and MongoDB to build full featured web applications. A basic understanding of JavaScript and HTML is the only requirement for this book.
Table of Contents (14 chapters)
12
12. Popular Node.js Web Frameworks
13
Index

Helpers for reusable code


So far, each of the pages that we have rendered displays its viewModel data perfectly, but that pesky sidebar still remains blank. We're going to fix this by creating a few modules for the sidebar content but implementing them as helper modules. These helper modules are those that will be used repeatedly by various parts of our application and don't necessary belong to the controller folder or the server folder. So, we'll just create a new home called helpers and store these modules there.

Note

As we are just loading temporary fixture data into our view models, the data we set up in the helpers as well as the controllers will all be replaced with actual live data in the next chapter once we implement MongoDB.

The sidebar module

First, we will create a module for the entire sidebar. This module will be responsible for calling multiple other modules to populate viewModel for each section of the sidebar. As we are going to be populating each page's own viewModel with data...