Hi K,
> It is a good idea to take out express,
Well I thought about it overnight, basically the options are:
1) Keep the existing (0.x) behavior and hardcode Express;
dependencies: "express": "4.8.8"
@express = require 'express'
Obviously doesn't work well since it prevents easy upgrades to Express
independently from Zappa.
2) Leave Express dependency open, latest Express 4 is used
dependencies: "express": "^4"
@express = require 'express'
Basically we lose control over everything, tests are meaningless.
3) Do not include Express in ZappaJS
@express = require 'express'
Makes first-time use more difficult, you need to manually install
express; also need to remember to `npm install --save` even for
old-timers. Too cumbersome.
4) Hardcode Express but allow to override it using an option (similar to
what was implemented by twhtanghk for
socket.io);
dependencies: "express": "4.8.8"
@express = options.express ? require 'express'
I think 1-3 all have maintainability / dependency graph / test issues,
and #4 is the best approach: it provides a meaningul, tested default,
but allows power-users to upgrade at will. It's also consistent with how
we treat
socket.io.
This can also be extended to express-session and serve-static if needed.
There's a similar-but-not-quite-identical issue with jquery, sammy, and
socket.io-client. The current (1.0.4) README says:
If you also intend to @use 'zappa' or reference ZappaJS's client
Javascript (which is the case for most of the examples):
npm install socket.io-client jquery git+
https://github.com/quirkey/sammy.git
which in retrospect is the worst thing I could have done. :( I'll revert
this to provide defaults and allow override.
While I'm at it I might reference the comments I made in GH#102 and
summarize them here:
- No backported solutions to middleware. Use the new Express middleware
packages:
@use (require 'body-parser').urlencoded()
- Extended ZappaJS to require the module on the fly:
@use morgan:'combined'
works as long as you `npm install morgan` in your app.
- Added `@session` as a reference to the `export-session` module in the
root scope:
ExpressRedisStore = (require 'connect-redis') @session
@use session:
store: new ExpressRedisStore redis_config
secret: the_secret
> if there were no speed bumps I'd even suggest taking out coffeescript
Yup, coffee-script is only a devDependency now.
S.