Fix: boom error on invalid include
Sends a 501 `notImplemented` error when `parseInclude` can't find models to include.
This commit is contained in:
parent
38ccb3adf6
commit
f2f613b35b
@ -1,4 +1,5 @@
|
|||||||
import { omit, identity } from 'lodash';
|
import { omit, identity } from 'lodash';
|
||||||
|
import { notImplemented } from 'boom';
|
||||||
|
|
||||||
export const parseInclude = request => {
|
export const parseInclude = request => {
|
||||||
const include = Array.isArray(request.query.include) ? request.query.include
|
const include = Array.isArray(request.query.include) ? request.query.include
|
||||||
@ -8,7 +9,7 @@ export const parseInclude = request => {
|
|||||||
const noRequestModels = !request.models;
|
const noRequestModels = !request.models;
|
||||||
|
|
||||||
if (noGetDb && noRequestModels) {
|
if (noGetDb && noRequestModels) {
|
||||||
return new Error('`request.getDb` or `request.models` are not defined.'
|
return notImplemented('`request.getDb` or `request.models` are not defined.'
|
||||||
+ 'Be sure to load hapi-sequelize before hapi-sequelize-crud.');
|
+ 'Be sure to load hapi-sequelize before hapi-sequelize-crud.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user