From f0d34a69b6b42a9b41aa99550a6d8e02653fbdb7 Mon Sep 17 00:00:00 2001 From: scott-wyatt Date: Tue, 31 Jul 2018 19:07:48 -0400 Subject: [PATCH 1/2] [feat] throw error if misconfigured resolver --- lib/transformer.ts | 4 ++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/transformer.ts b/lib/transformer.ts index 6f6a138..00bd78d 100755 --- a/lib/transformer.ts +++ b/lib/transformer.ts @@ -182,6 +182,10 @@ export const Transformer = { const options = Transformer.getModelOptions(app, model) const schema = Transformer.getModelSchema(app, model) + if (!model.resolver || !model.resolver.connect) { + throw new Error(`${modelName} was set to use Sequelize but the resolver is missing "connect"`) + } + model.store = store model.migrate = migrate model.resolver.connection = connection diff --git a/package-lock.json b/package-lock.json index 6f4592b..8910a5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e71ad4f..905671d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fabrix/spool-sequelize", - "version": "1.1.2", + "version": "1.1.3", "description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com", "scripts": { "build": "tsc -p ./lib/tsconfig.release.json", From 913a0f6acaf1978ca06dbc8f3c39c3d1fa6a323d Mon Sep 17 00:00:00 2001 From: scott-wyatt Date: Tue, 31 Jul 2018 19:10:16 -0400 Subject: [PATCH 2/2] [feat] check that resolver is a sequelize resolver --- lib/transformer.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/transformer.ts b/lib/transformer.ts index 00bd78d..0356d1b 100755 --- a/lib/transformer.ts +++ b/lib/transformer.ts @@ -3,6 +3,7 @@ import * as Sequelize from 'sequelize' import { FabrixApp } from '@fabrix/fabrix' import { FabrixModel } from '@fabrix/fabrix/dist/common' import { pickBy, isString, startsWith } from 'lodash' +import { SequelizeResolver } from './SequelizeResolver' export const Transformer = { BreakException: {}, @@ -185,6 +186,9 @@ export const Transformer = { if (!model.resolver || !model.resolver.connect) { throw new Error(`${modelName} was set to use Sequelize but the resolver is missing "connect"`) } + if (!(model.resolver instanceof SequelizeResolver)) { + throw new Error(`${modelName} is not a Sequelize Resolver`) + } model.store = store model.migrate = migrate