Permalink
Browse files

[fix] allow configurations per environment

  • Loading branch information...
1 parent 0c7a0e1 commit 2a550470866535e8e792e06c28dc378cb16d9c62 @Swaagie Swaagie committed May 21, 2014
Showing with 33 additions and 21 deletions.
  1. +30 −18 config/index.js
  2. +1 −1 lib/mongo.js
  3. +1 −1 lib/pre-startup.js
  4. +1 −1 package.json
View
@@ -1,24 +1,36 @@
-/**
- * REQUIRED: MongoDB connection string. Example: mongoHQ via nodejitsu
- *
- * @type {String}
- */
-exports.mongo = 'mongodb://localhost:27017/ghost';
+'use strict';
-/**
- * Which themes should be added to /themes, provide as { name: source }.
- * Source can either be a valid git URL or the name of a submodule.
- *
- * @type {Object}
- */
-exports.themes = {
- casper: 'git://github.com/TryGhost/Casper.git'
+//
+// Configuration per environment, development is default. Configuration options:
+// - mongo: {String} MongoDB connection. Example: mongoHQ via nodejitsu.
+// - themes: {Object} name:source combination, valid git URL or submodule name.
+// - mail: {Object} optional e-mail service, required for password recovery.
+//
+var config = {
+ development: {
+ mongo: 'mongodb://localhost:27017/blog',
+ themes: {
+ casper: 'git://github.com/TryGhost/Casper.git'
+ },
+ mail: {}
+ },
+
+ production: {
+ mongo: 'mongodb://localhost:27017/blog',
+ themes: {
+ casper: 'git://github.com/TryGhost/Casper.git'
+ },
+ mail: {}
+ }
};
/**
- * OPTIONAL: Provide e-mail service configuration, not providing these details will
- * disable password recovery, also a closeable warning is shown.
+ * Return the correct configuration based on environment.
*
- * @type {Array}
+ * @param {String} env environment setting
+ * @return {Object} configuration
+ * @api public
*/
-exports.mail = {};
+module.exports = function get(env) {
+ return env in config ? config[env] : config.development;
+};
View
@@ -8,7 +8,7 @@ var url = require('url')
, MongoClient = mongo.MongoClient
, GridStore = mongo.GridStore
, ObjectID = mongo.ObjectID
- , config = require('../config')
+ , config = require('../config')(process.env.NODE_ENV)
, database;
//
View
@@ -9,7 +9,7 @@ var fs = require('fs')
, async = require('async')
, path = require('path')
, colors = require('colors')
- , local = require('../config')
+ , local = require('../config')(process.env.NODE_ENV)
, pkg = require('../package')
, Mongo = require('./mongo')
, mongo = new Mongo;
View
@@ -1,6 +1,6 @@
{
"name": "persistent-ghost",
- "version": "0.7.1",
+ "version": "0.7.2",
"description": "Wrapper to deploy the Ghost blog on Nodejitsu",
"main": "index.js",
"scripts": {

0 comments on commit 2a55047

Please sign in to comment.