Comparing version 3.0.0-pre.4 to 3.0.0
/** | ||
* Database Configuration | ||
* (app.config.database) | ||
* Datastore Configuration | ||
* (app.config.stores) | ||
* | ||
@@ -5,0 +5,0 @@ * Configure the ORM layer, connections, etc. |
@@ -1,2 +0,2 @@ | ||
/*eslint no-process-env: 0 */ | ||
/*eslint no-process-env: 0, no-console: 0 */ | ||
@@ -99,2 +99,3 @@ const EventEmitter = require('events').EventEmitter | ||
catch (e) { | ||
console.log(e.stack) | ||
throw new TrailpackError(Pack, e, 'constructor') | ||
@@ -104,5 +105,8 @@ } | ||
// bind resource methods | ||
// instantiate resource classes and bind resource methods | ||
this.controllers = lib.Core.bindMethods(this, 'controllers') | ||
this.policies = lib.Core.bindMethods(this, 'policies') | ||
this.services = lib.Core.bindMethods(this, 'services') | ||
this.models = lib.Core.bindMethods(this, 'models') | ||
this.resolvers = lib.Core.bindMethods(this, 'resolvers') | ||
@@ -109,0 +113,0 @@ lib.Core.bindApplicationListeners(this) |
const merge = require('lodash.merge') | ||
const path = require('path') | ||
const joi = require('joi') | ||
const schemas = require('./schemas') | ||
@@ -7,7 +9,7 @@ const ConfigurationProxyHandler = { | ||
if (target.has && target.has(key)) { | ||
const value = target.immutable ? Object.freeze(target.get(key)) : target.get(key) | ||
const value = target.immutable === true ? Object.freeze(target.get(key)) : target.get(key) | ||
return new Proxy(value, ConfigurationProxyHandler) | ||
} | ||
else { | ||
return target.immutable ? Object.freeze(target[key]) : target[key] | ||
return target.immutable === true ? Object.freeze(target[key]) : target[key] | ||
} | ||
@@ -23,3 +25,3 @@ } | ||
this.validateConfig() | ||
this.validateConfig(config) | ||
@@ -38,6 +40,5 @@ this.immutable = false | ||
set (key, value) { | ||
if (this.immutable) { | ||
if (this.immutable === true) { | ||
throw new IllegalAccessError('Cannot set properties directly on config. Use .set(key, value) (immutable)') | ||
} | ||
return super.set(key, value) | ||
@@ -73,2 +74,5 @@ } | ||
/** | ||
* Flattens configuration tree | ||
*/ | ||
static flattenTree (tree = { }) { | ||
@@ -129,5 +133,3 @@ const toReturn = { } | ||
*/ | ||
validateConfig () { | ||
/* | ||
TODO re-enable | ||
validateConfig (config) { | ||
const result = joi.validate(config, schemas.config) | ||
@@ -137,5 +139,4 @@ if (result.error) { | ||
} | ||
*/ | ||
} | ||
} | ||
@@ -93,4 +93,4 @@ /*eslint no-console: 0 */ | ||
mergeApi (app, pack) { | ||
console.log('app.api', app.api) | ||
console.log('pack.api', pack.api) | ||
pack.api || (pack.api = { }) | ||
Object.assign(app.api.controllers, pack.api.controllers) | ||
@@ -173,5 +173,5 @@ Object.assign(app.api.services, pack.api.services) | ||
bindTrailpackMethodListeners (app, pack) { | ||
const lifecycle = pack.lifecycle | ||
const lifecycle = pack.lifecycle || { } | ||
app.after(lifecycle.initialize.listen.concat('trailpack:all:configured')) | ||
app.after(((lifecycle.initialize || { }).listen || [ ]).concat('trailpack:all:configured')) | ||
.then(() => app.log.debug('trailpack: initializing', pack.name)) | ||
@@ -182,3 +182,3 @@ .then(() => pack.initialize()) | ||
app.after(lifecycle.configure.listen.concat('trailpack:all:validated')) | ||
app.after(((lifecycle.configure || { }).listen || [ ]).concat('trailpack:all:validated')) | ||
.then(() => app.log.debug('trailpack: configuring', pack.name)) | ||
@@ -185,0 +185,0 @@ .then(() => pack.configure()) |
@@ -12,3 +12,3 @@ const joi = require('joi') | ||
env: joi.string().required(), | ||
env: joi.string(), //.required(), // scott-wyatt: env is often undefined and can not be required. | ||
@@ -15,0 +15,0 @@ log: joi.object().keys({ |
{ | ||
"name": "trails", | ||
"version": "3.0.0-pre.4", | ||
"version": "3.0.0", | ||
"description": "Modern Web Application Framework for Node.js", | ||
@@ -58,2 +58,7 @@ "keywords": [ | ||
"email": "mike@epicfirm.com" | ||
}, | ||
{ | ||
"name": "Scott Wyatt", | ||
"email": "scottwyatt86@gmail.com", | ||
"url": "https://github.com/scott-wyatt" | ||
} | ||
@@ -92,6 +97,3 @@ ], | ||
}, | ||
"publishConfig": { | ||
"tag": "next" | ||
}, | ||
"runkitExample": "test/runkitExample.js" | ||
} |
@@ -98,2 +98,3 @@ <img src="http://cdn.trailsjs.io/art/logos/trails-horiz-logo-green.svg" height="96px" title="Trails Logo" /> | ||
- [Trails.js Website](http://trailsjs.io/support) | ||
- [Stackoverflow](http://stackoverflow.com/questions/tagged/trailsjs) | ||
@@ -100,0 +101,0 @@ ## FAQ |
@@ -12,44 +12,12 @@ const fs = require('fs') | ||
describe('@TrailsApp', () => { | ||
describe.skip('idempotence', () => { | ||
describe('no side effects', () => { | ||
it('should be able to start and stop many instances in a single node process', () => { | ||
const cycles = [ ] | ||
for (let i = 0; i < 10; ++i) { | ||
cycles.push(new Promise (resolve => { | ||
const app = new TrailsApp(testAppDefinition) | ||
app.start(testAppDefinition) | ||
.then(app => { | ||
assert.equal(app.started, true) | ||
resolve(app) | ||
}) | ||
})) | ||
cycles.push(new TrailsApp(testAppDefinition).start()) | ||
} | ||
return Promise.all(cycles) | ||
.then(apps => { | ||
return Promise.all(apps.map(app => { | ||
return app.stop() | ||
})) | ||
}) | ||
.then(apps => { | ||
apps.map(app => { | ||
assert.equal(app.stopped, true) | ||
}) | ||
}) | ||
.then(apps => Promise.all(apps.map(app => app.stop()))) | ||
}) | ||
it('should be able to stop, then start the same app', () => { | ||
const app = new TrailsApp(testAppDefinition) | ||
return app.start(testAppDefinition) | ||
.then(app => { | ||
assert.equal(app.started, true) | ||
return app.stop() | ||
}) | ||
.then(app => { | ||
assert.equal(app.stopped, true) | ||
return app.start(testAppDefinition) | ||
}) | ||
.then(app => { | ||
assert.equal(app.started, true) | ||
return app.stop() | ||
}) | ||
}) | ||
}) | ||
@@ -56,0 +24,0 @@ describe('#constructor', () => { |
@@ -197,3 +197,3 @@ const assert = require('assert') | ||
describe('#validateConfig', () => { | ||
it.skip('should throw ValidationError if main.packs contains an "undefined" trailpack', () => { | ||
it('should throw ValidationError if main.packs contains an "undefined" trailpack', () => { | ||
const testConfig = { | ||
@@ -248,10 +248,10 @@ main: { | ||
}) | ||
it.skip('should throw an error when attempting to set a value after frozen', () => { | ||
it('should throw an error when attempting to set a value after frozen', () => { | ||
const config = new lib.Configuration(_.cloneDeep(testConfig), { NODE_ENV: 'test' }) | ||
config.freeze() | ||
//assert.throws(() => config.customObject = 'test', IllegalAccessError) | ||
//assert.throws(() => config.customObject.newValue = 'test', IllegalAccessError) | ||
assert.throws(() => config.customObject.string = 'b', IllegalAccessError) | ||
assert.throws(() => config.set('customObject.string', 'b'), IllegalAccessError) | ||
assert.throws(() => config.set('customObject.string', 'b'), lib.Errors.IllegalAccessError) | ||
// TODO re-enable | ||
// assert.throws(() => config.customObject.string = 'c', lib.Errors.IllegalAccessError) | ||
// assert.throws(() => config.customObject['string'] = 'c', lib.Errors.IllegalAccessError) | ||
}) | ||
@@ -258,0 +258,0 @@ }) |
@@ -0,1 +1,2 @@ | ||
/* eslint new-cap: [0] */ | ||
const assert = require('assert') | ||
@@ -73,3 +74,3 @@ const Trailpack = require('trailpack') | ||
describe('#message', () => { | ||
it.skip('should specifiy missing/undefined trailpacks', () => { | ||
it('should specify missing/undefined trailpacks', () => { | ||
const testConfig = { | ||
@@ -84,3 +85,3 @@ main: { | ||
try { | ||
lib.Configuration.validateConfig(testConfig) | ||
new lib.Configuration(testConfig) | ||
} | ||
@@ -87,0 +88,0 @@ catch (e) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
236442
91
6026
0
125