September 2014
Intermediate to advanced
316 pages
7h 6m
English
One thing you can do to extend an application if you are building a larger site is to build it using MVC (Model, View, Controller). We already have the view part sorted, so let's look at the other pieces. We have some sort of a controller setup with our routes directory. The next step will be to create a file for each. For example, we can have account.js, which will have the login, logout, and createAccount functions. We haven't really covered adding models to our app. We can create a directory called models, and then add a user model, for which we can find a user, update, and create a user to tie in with our account controller. Note that there are some other frameworks that build on Express in this way (sails.js ...