Update to Express 4.0, express-handlebars, and organize code
In this version, I upgraded some of the project dependencies and organized the file and folder structure. The notable mentions for this release are:
Dependencies
- Uses Express 4.x now (bumped up from Express 3.x)
- Uses express-handlebars (previously known as express3-handlebars)
Project Structure
- The
config/
folder now stores config data for the app. This is also where commonly used paths are now stored. - There is now a
routes/
folder, that exposes theroutes.render(viewName)
method. If you pass in a[viewName]
, it will render[viewName].handlebars
. It also has aroutes.redirect(url, statusCode)
method. - The
lib/
folder has some nice JavaScript and Handlebars helpers. I find the Handlebars helpers particularly useful. The following helpers are included:{{addLocalJS}}
- Supply a path to a local JS file and that file will get loaded.{{addLocalCSS}}
- Supply a path to a local CSS file and that file will get loaded.{{addRemoteCSS}}
- Supply a path to a remote CSS file and that file will get loaded.{{setTitle}}
- Sets the page title.
These helpers are useful for modularizing your JS/CSS on a per-page level, so you don't have monolithic stylesheets and JS files.
Front-end
- Load jQuery 2.x and Bootstrap 3.x by default, since these are popular libraries that most people seem to use. If you want to remove them, just remove the references from
views/layouts/main.handlebars
. - Add an empty stylesheet to
public/css/app.css
so people can start modifying that.
Happy coding!