mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	#18 any-db-postgres, dbPool.js
This commit is contained in:
		
							parent
							
								
									33acc4ea71
								
							
						
					
					
						commit
						2ca8291eac
					
				@ -33,5 +33,9 @@ module.exports = function (app) {
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    app.patch('/features/:id', function (req, res) {
 | 
			
		||||
        res.status(500).end();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
var Promise = require('bluebird');
 | 
			
		||||
var featuresMock = require('./featuresMock');
 | 
			
		||||
// var dbPool = require('./dbPool');
 | 
			
		||||
 | 
			
		||||
function getFeature(name) {
 | 
			
		||||
    var featureFound;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								unleash-server/lib/dbPool.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								unleash-server/lib/dbPool.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
var anyDB = require('any-db'),
 | 
			
		||||
    logger = require('./logger'),
 | 
			
		||||
    nconf = require('nconf'),
 | 
			
		||||
    fs = require('fs'),
 | 
			
		||||
    ini = require('ini');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function createDbPool() {
 | 
			
		||||
    if (nconf.argv().get('databaseini') !== undefined) {
 | 
			
		||||
        var databaseini = nconf.argv().get('databaseini');
 | 
			
		||||
 | 
			
		||||
        logger.info('unleash started with databaseini: ' + databaseini);
 | 
			
		||||
 | 
			
		||||
        var config = ini.parse(fs.readFileSync(databaseini, 'utf-8'));
 | 
			
		||||
 | 
			
		||||
        return anyDB.createPool(config.DATABASE_URL, {min: 2, max: 20});
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    pool: createDbPool()
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										53
									
								
								unleash-server/lib/eventMock.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								unleash-server/lib/eventMock.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
module.exports = [
 | 
			
		||||
    {
 | 
			
		||||
        "id": 1,
 | 
			
		||||
        "created": "2014-08-01 12:22:00",
 | 
			
		||||
        "type": "feature-create",
 | 
			
		||||
        "user": "John, Doe",
 | 
			
		||||
        "comment": "Optional comment",
 | 
			
		||||
        "data": {
 | 
			
		||||
            "name": "com.example.feature",
 | 
			
		||||
            "status": "off",
 | 
			
		||||
            "strategy": "default",
 | 
			
		||||
            "description": "Feature description"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "id": 2,
 | 
			
		||||
        "created": "2014-09-02 15:23:11",
 | 
			
		||||
        "type": "feature-update",
 | 
			
		||||
        "user": "User name",
 | 
			
		||||
        "comment": "Optional comment",
 | 
			
		||||
        "data": {
 | 
			
		||||
            "name": "com.example.feature",
 | 
			
		||||
            "status": "on"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "id": 3,
 | 
			
		||||
        "created": "1970-01-01 00:00:00",
 | 
			
		||||
        "type": "strategy-create",
 | 
			
		||||
        "user": "User name",
 | 
			
		||||
        "comment": "Optional comment",
 | 
			
		||||
        "data": {
 | 
			
		||||
            "name": "strategyA",
 | 
			
		||||
            "parameters_template": {
 | 
			
		||||
                "users": "example values",
 | 
			
		||||
                "target_age": "number"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "id": 4,
 | 
			
		||||
        "created": "1970-01-01 00:00:00",
 | 
			
		||||
        "type": "strategy-update",
 | 
			
		||||
        "user": "localhost.localdomain",
 | 
			
		||||
        "comment": "commit message goes here",
 | 
			
		||||
        "data": {
 | 
			
		||||
            "name": "strategyA",
 | 
			
		||||
            "parameters_template": {
 | 
			
		||||
                "users": "new default example values"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
];
 | 
			
		||||
@ -38,7 +38,9 @@
 | 
			
		||||
        "ini": "1.3.0",
 | 
			
		||||
        "log4js": "0.6.21",
 | 
			
		||||
        "nconf": "0.6.9",
 | 
			
		||||
        "pg": "^3.6.1"
 | 
			
		||||
        "pg": "^3.6.1",
 | 
			
		||||
        "any-db": "2.1.0",
 | 
			
		||||
        "any-db-postgres": "2.1.3"
 | 
			
		||||
    },
 | 
			
		||||
    "devDependencies": {
 | 
			
		||||
        "chai": "1.9.1",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user