aboutsummaryrefslogtreecommitdiff
path: root/services/votes/votes.hooks.ts
blob: 63f19e36429cd9246ca1f71f18c80c340bf2780e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { HookContext } from '@feathersjs/feathers';
import { authenticate } from '@feathersjs/authentication';

const addUserId = async (context: HookContext): Promise<HookContext> => {
  const { params: { user} } = context;
  context.data.userId = user._id;
  return context;
};

export default {
  before: {
    create: [authenticate('jwt'), addUserId]
  }
};