Merge pull request #96 from strongloop/feature/config

Make all app config values available from `app.get()`
This commit is contained in:
Ritchie Martori 2013-12-12 16:01:43 -08:00
commit 5a154072a1
4 changed files with 25 additions and 18 deletions

View File

@ -252,6 +252,13 @@ app.boot = function(options) {
app.set('port', appConfig.port);
}
for(var configKey in appConfig) {
var cur = app.get(configKey);
if(cur === undefined || cur === null) {
app.set(configKey, appConfig[configKey]);
}
}
// instantiate data sources
forEachKeyedObject(dataSourceConfig, function(key, obj) {
app.dataSource(key, obj);

View File

@ -35,7 +35,8 @@
"loopback-datasource-juggler": "~1.2.0",
"mocha": "~1.14.0",
"strong-task-emitter": "0.0.x",
"supertest": "~0.8.1"
"supertest": "~0.8.1",
"chai": "~1.8.1"
},
"repository": {
"type": "git",

View File

@ -31,21 +31,7 @@ describe('app', function() {
assert(f instanceof loopback.Model);
});
})
// describe('app.models()', function() {
// it("Get the app's exposed models", function() {
// var app = loopback();
// var models = app.models();
// models.forEach(function(m) {
// console.log(m.modelName);
// })
// assert.equal(models.length, 1);
// assert.equal(models[0].modelName, 'color');
// });
// });
});
describe('app.boot([options])', function () {
beforeEach(function () {
@ -54,7 +40,9 @@ describe('app', function() {
app.boot({
app: {
port: 3000,
host: '127.0.0.1'
host: '127.0.0.1',
foo: {bar: 'bat'},
baz: true
},
models: {
'foo-bar-bat-baz': {
@ -72,11 +60,21 @@ describe('app', function() {
});
});
it('Load configuration', function () {
it('should have port setting', function () {
assert.equal(this.app.get('port'), 3000);
});
it('should have host setting', function() {
assert.equal(this.app.get('host'), '127.0.0.1');
});
it('should have other settings', function () {
expect(this.app.get('foo')).to.eql({
bar: 'bat'
});
expect(this.app.get('baz')).to.eql(true);
});
describe('PaaS and npm env variables', function() {
beforeEach(function() {
this.boot = function () {

View File

@ -3,6 +3,7 @@
*/
assert = require('assert');
expect = require('chai').expect;
loopback = require('../');
memoryConnector = loopback.Memory;
GeoPoint = loopback.GeoPoint;