diff options
Diffstat (limited to 'services/votes/votes.hooks.ts')
-rw-r--r-- | services/votes/votes.hooks.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/services/votes/votes.hooks.ts b/services/votes/votes.hooks.ts new file mode 100644 index 0000000..1cf7261 --- /dev/null +++ b/services/votes/votes.hooks.ts @@ -0,0 +1,15 @@ +import { HookContext } from '@feathersjs/feathers'; +import requireAuth from '../../hooks/requireAuth'; + +const addUserId = async (context: HookContext): Promise<HookContext> => { + const { params: { user} } = context; + context.data.userId = user._id; + return context; +}; + +export default { + before: { + create: [requireAuth, addUserId] + } +}; + |