Permalink
Browse files

Added simple json-config example

for some who might prefer this. there are benefits to both
  • Loading branch information...
1 parent d3c4fd9 commit d8b20bd2d510ad24997122acb88a835c638be9d2 @tj tj committed Sep 13, 2011
Showing with 49 additions and 0 deletions.
  1. +26 −0 examples/json-config/app.js
  2. +19 −0 examples/json-config/config.js
  3. +4 −0 examples/json-config/views/index.jade
@@ -0,0 +1,26 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('../../');
+
+app = express.createServer();
+
+// load the config for this environment (NODE_ENV)
+
+var config = require('./config')[app.settings.env];
+
+// apply settings
+
+for (var key in config) app.set(key, config[key]);
+
+// apply middleware
+
+config.middleware.forEach(app.use.bind(app));
+
+app.get('/', function(req, res){
+ res.render('index', { layout: false });
+});
+
+app.listen(3000);
@@ -0,0 +1,19 @@
+
+// ok so it's not JSON, but close enough :)
+
+var express = require('../../');
+
+exports.development = {
+ 'view engine': 'jade'
+ , 'views': __dirname + '/views'
+ , 'title': 'My Site'
+ , 'middleware': [
+ express.logger('dev')
+ , app.router
+ , express.static(__dirname + '/public')
+ ]
+};
+
+exports.production = {
+
+};
@@ -0,0 +1,4 @@
+html
+ body
+ h1 #{settings.title}
+ p Simple example

0 comments on commit d8b20bd

Please sign in to comment.