Ironically, Sails is actually becoming less and less MVC focused internally (see https://github.com/sails101/like-express for an example of what you can do now) On a separate note, I've been gradually working on making the Express dep optional in sails core for a while now. Features like views/static middleware/the orm/etc should be swappable IMO, e.g. you might only need/want socket.io. That was the whole idea of the "hooks" thing in 0.9 (original proposal.
So anyways I thought it might be useful to list how I'm applying Express 3 in Sails as a data point/use case:
Nowadays, Sails core (minus the cli) is essentially:
aka "request interpreter"
https://github.com/balderdashy/sails/tree/master/lib/router
(currently uses express, could use routification, but it is not HTTP specific-- you can bind routes w/ app.post()
etc. and then simulate requests using app.request()
)
https://github.com/balderdashy/sails/tree/master/lib/app
This takes care of basic default config, and uses @dominictarr's rc module (also has some utility functions)
Would love to see this simplified into a thing that lets you extend the req and res objects (currently I'm extending them using middleware injected in hooks e.g. function _addResViewMethod(req,res,next){ res.view=function(){...}; next(); }
)
https://github.com/balderdashy/sails/tree/master/lib/hooks (this is the thing that loads the hooks)
Worth mentioning is that the http
hook actually builds an express app and can "lift" it on a port, whereas the router mentioned above is completely protocol-agnostic.
Then there are 20-odd hooks that are built in to core that I haven't taken the time to pull out into separate modules-- they can be overridden, and additional hooks can be added programmatically or using the .sailsrc file. They're like plugins. In many cases, hooks correspond loosely with middleware, but they also get an initialize(cb)
function where they can tap into the framework boot. The hooks built in to the framework implement various pieces of the core MVC+sockets+pubsub functionality in Sails. Consequently, I'd say they represent the only part of our setup that is really MVC-only, or "sails"-y if you will. Some hooks are tiny and just call out to other modules (like "grunt"), while other hooks are much larger (like "orm", even though it calls out to waterline.) With waterline2 (let me know if you want me to add you to play around w/ it) it'll be considerably cleaner.
https://github.com/balderdashy/sails/blob/master/lib/app/configuration/defaultHooks.js
Here are the default hooks as of v0.10:
(they should all be separate node modules)