Trees
Trees is a wrapper around the very awesome express.js module that provides a more structured and common MVC framework to work with. You gain the benefit of tested MVC structure and the stability and features of express (a win/win)!
Usage
NOTE: It's important to note that Trees in a very early alpha stage and these instructions are almost guaranteed to change soon or break.
Install
Install the trees module globally first.
$ npm install -g tree-server
Create a New Trees Application
$ trees new application
$ cd application
$ npm install
Create A Controller
Review the default generated controller. You should see:
var ooj = BaseController = BaseController; // Define our Pages Controller, the use of OOJ is here to make extending// the BaseController simpler and less involved.moduleexports = ooj;
Check the config/routes.js
and see how trees knows which controller and action
to perform for which route. You can see we've defined the root path (/
) to point
to the pages
controllers home
action.
var app = ; apptreesrouter;
NOTE: The resources
has not yet been implemented and namespace
has not
been fully tested so may not function properly with views/controllers.
Finally we'll check the view that is rendered at app/views/pages/home.jade
:
extends ../layouts/application block body div h1 Hello, #{name}
This view extends the base application layout and simply outputs a div
with
an h1
inside of it.
Run Trees!
Finally, run your server! For now, we do it all manually. I'm planning on adding
in a trees server
that will run the server with a live reload feature (etc...)
in the future.
$ node index.js
And finally, go to localhost:3000
in your browser!
Author
Brandon Buck lordizuriel@gmail.com