Added -s, --session[s] support to express(1)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This adds cookieDecoder() / session() middleware for you
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent d909dd2 · Browse files · 2 files·+29 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+29 added−7 removed
- other:+29 added−7 removed
Provenance
- Commit
1a6d245- Tree
c31b2dc- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
d909dd2
2 files changed+29 added−7 removed
modified:bin/express+27 added-6 removed
19 unmodified lines20 21 var stdin;22 23 /**24+ * Add session support.25+ */26+27+var sessions = false;28+29+/**30 * CSS engine to utilize.31 */32 33 var cssEngine = 'none';5 unmodified lines39 var usage = ''40 + '\x1b[1mUsage\x1b[0m: express [options] [PATH]\n'41 + '\n'42 + '\x1b[1mOptions\x1b[0m:\n'43+ + ' -s, --sessions Add session support\n'37- + ' -c, --css ENGINE Utilize stylesheet ENGINE (less|sass). Defaults to plain css\n'38- + ' -v, --version Output framework version\n'39- + ' -h, --help Output help information\n';44+ + ' -c, --css ENGINE Add stylesheet ENGINE support (less|sass). Defaults to plain css\n'45+ + ' -v, --version Output framework version\n'46+ + ' -h, --help Output help information\n'47+ ;48 49 /**50 * Jade layout template.51 */93 unmodified lines145 , 'app.configure(function(){'146 , ' app.set(\'views\', __dirname + \'/views\');'147 , ' app.set(\'view engine\', \'jade\');'148 , ' app.use(express.bodyDecoder());'141- , ' app.use(express.methodOverride());__CSS__'149+ , ' app.use(express.methodOverride());:SESS:CSS'150 , ' app.use(app.router);'151 , ' app.use(express.staticProvider(__dirname + \'/public\'));'152 , '});'153 , ''39 unmodified lines193 case '-v':194 case '--version':195 abort(version);196 break;197+ case '-s':198+ case '--session':199+ case '--sessions':200+ sessions = true;201+ break;202 case '-c':203 case '--css':204 args.length205 ? (cssEngine = args.shift())53 unmodified lines259 });260 mkdir(path + '/test', function(){261 write(path + '/test/app.test.js', appTest);262 });263+264+ // CSS Engine support265 switch (cssEngine) {266 case 'sass':267 case 'less':253- app = app.replace('__CSS__', '\n app.use(express.compiler({ src: __dirname + \'/public\', enable: [\'' + cssEngine + '\'] }));');268+ app = app.replace(':CSS', '\n app.use(express.compiler({ src: __dirname + \'/public\', enable: [\'' + cssEngine + '\'] }));');269 break;270 default:256- app = app.replace('__CSS__', '');271+ app = app.replace(':CSS', '');272 }273+274+ // Session support275+ app = app.replace(':SESS', sessions276+ ? '\n app.use(express.cookieDecoder());\n app.use(express.session());'277+ : '');278+279 write(path + '/app.js', app);280 });281 }282 81 unmodified linesmodified:docs/executable.md+2 added-1 removed
9 unmodified lines101112131414151617189 unmodified linesapplication structure, this executable creates a maintainable base app.
## Options
-s, --sessions Add session support -c, --css ENGINE Utilize css ENGINE (less|sass). Defaults to plain css -c, --css ENGINE Add css ENGINE support (less|sass). Defaults to plain css -v, --version Output framework version -h, --help Display help information