From afe9a3b3d49897eff045ee237ca2937a6b975291 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 17 May 2022 15:20:38 -0700 Subject: [PATCH] fix(core): Do not throw missing method error for regular hook methods (#2636) --- packages/feathers/src/hooks/regular.ts | 2 +- packages/feathers/test/hooks/before.test.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/feathers/src/hooks/regular.ts b/packages/feathers/src/hooks/regular.ts index ff01715184..7c08eb6b9a 100644 --- a/packages/feathers/src/hooks/regular.ts +++ b/packages/feathers/src/hooks/regular.ts @@ -142,7 +142,7 @@ const createMap = (input: RegularHookMap, methods: string[]) => { const data = convertHookData(input[type]); Object.keys(data).forEach((method) => { - if (method !== 'all' && !methods.includes(method)) { + if (method !== 'all' && !methods.includes(method) && !defaultServiceMethods.includes(method)) { throw new Error(`'${method}' is not a valid hook method`); } }); diff --git a/packages/feathers/test/hooks/before.test.ts b/packages/feathers/test/hooks/before.test.ts index 4443341375..70b458c9e1 100644 --- a/packages/feathers/test/hooks/before.test.ts +++ b/packages/feathers/test/hooks/before.test.ts @@ -38,7 +38,9 @@ describe('`before` hooks', () => { return new Promise((_resolve, reject) => { reject(new Error('This did not work')); }); - } + }, + + find: [] } });