Skip to content

Commit

Permalink
Merge pull request #27 from fabrix-app/v1.6
Browse files Browse the repository at this point in the history
[fix] fixes #26 error not being thrown
  • Loading branch information
scott-wyatt authored Dec 19, 2018
2 parents a5674b2 + 9f25a07 commit 4acaadf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/SequelizeSpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ export class SequelizeSpool extends DatastoreSpool {
if (stores && Object.keys(stores).length === 0) {
this.app.log.warn('No store configured at config.stores, models will be ignored')
}
const models = this.app.config.get('models')
if (!models) {
this.app.log.warn('No models configured at config.models, models will be ignored')
}
return Promise.all([
Validator.validateStoresConfig(this.app.config.get('stores'))
Validator.validateStoresConfig(stores),
Validator.validateModelsConfig(models)
])
}

Expand Down
1 change: 1 addition & 0 deletions lib/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const joi = require('joi')

export const Schemas = {
storesConfig: joi.object(),
modelsConfig: joi.object(),

models: joi.object().keys({
autoPK: joi.boolean(),
Expand Down
10 changes: 10 additions & 0 deletions lib/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ export const Validator = {
return resolve(value)
})
})
},
validateModelsConfig (config) {
return new Promise((resolve, reject) => {
joi.validate(config, Schemas.modelsConfig, (err, value) => {
if (err) {
return reject(err)
}
return resolve(value)
})
})
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fabrix/spool-sequelize",
"version": "1.6.1",
"version": "1.6.2",
"description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com",
"scripts": {
"build": "tsc -p ./lib/tsconfig.release.json",
Expand Down

0 comments on commit 4acaadf

Please sign in to comment.