Skip to content

Commit

Permalink
[fix] should not have unset resources
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-wyatt committed Jun 28, 2018
1 parent 1010b18 commit 29d9fcd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Configuration extends Map<any, any> {
}
}

static initialResources (tree, resources = ['controllers', 'policies', 'services', 'models', 'resolvers']) {
static initialResources (tree, resources = []) {
if (tree.hasOwnProperty('main') && tree.main.hasOwnProperty('resources')) {
if (!isArray(tree.main['resources'])) {
throw new ConfigValueError('if set, main.resources must be an array')
Expand Down
3 changes: 2 additions & 1 deletion lib/Fabrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventEmitter } from 'events'
import { union } from 'lodash'
import { Core } from './Core'
import { Configuration } from './Configuration'
import { LoggerProxy } from './LoggerProxy'
Expand Down Expand Up @@ -94,7 +95,7 @@ export class FabrixApp extends EventEmitter {
this.setMaxListeners(this.config.get('main.maxListeners'))

// Set the resources from the configuration
this.resources = this.config.get('main.resources')
this.resources = union(Object.keys(app.api), this.config.get('main.resources'))

// Set each api resource to make sure it's provided as an object in app
this.resources.forEach(resource => {
Expand Down
2 changes: 1 addition & 1 deletion lib/Templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Templates = {

return (
` API
Resources : ${app.resources || []}
API Resources : ${resources ? app.resources : 'NONE INSTALLED'}
${ resources }
Spools : ${Object.keys(app.spools || {})}`
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fabrix/fabrix",
"version": "1.0.0-alpha.11",
"version": "1.0.0-alpha.12",
"description": "Strongly Typed Modern Web Application Framework for Node.js",
"keywords": [
"framework",
Expand Down
40 changes: 20 additions & 20 deletions test/integration/fabrixapp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,18 @@ describe('Fabrix', () => {
}
const app = new FabrixApp(def)
assert.deepEqual(app.config.get('main.resources'), [
'controllers',
'policies',
'services',
'models',
'resolvers'
// 'controllers',
// 'policies',
// 'services',
// 'models',
// 'resolvers'
])

assert(app['controllers'])
assert(app['services'])
assert(app['models'])
assert(app['resolvers'])
assert(app['policies'])
// assert(app['controllers'])
// assert(app['services'])
// assert(app['models'])
// assert(app['resolvers'])
// assert(app['policies'])
})

it('should override default resources', () => {
Expand Down Expand Up @@ -267,19 +267,19 @@ describe('Fabrix', () => {
}
const app = new FabrixApp(def)
assert.deepEqual(app.config.get('main.resources'), [
'controllers',
'policies',
'services',
'models',
'resolvers',
// 'controllers',
// 'policies',
// 'services',
// 'models',
// 'resolvers',
'events',
'customKey'
])
assert(app['controllers'])
assert(app['events'])
assert(app['models'])
assert(app['services'])
assert(app['resolvers'])
// assert(app['controllers'])
// assert(app['events'])
// assert(app['models'])
// assert(app['services'])
// assert(app['resolvers'])
assert(app['events'])
assert(app['customKey'])
})
Expand Down

0 comments on commit 29d9fcd

Please sign in to comment.