aboutsummaryrefslogtreecommitdiff
path: root/services/feedback/feedback.hooks.ts
blob: 7ae6c5d87805cc0d46f0c505b3c559c9f81abbe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { populate, discard } from 'feathers-hooks-common';
import requireAuth from '../../hooks/requireAuth';
import signAuthority from '../../hooks/signAuthority';
import sortByDate from '../../hooks/sortByDate';


const populateAuthor = populate({
  schema: {
    include: {
      service: 'users',
      nameAs: 'author',
      parentField: 'authorId',
      childField: '_id'
    }
  }
});

export default {
  before: {
    create: [requireAuth, signAuthority],
    find: sortByDate
  },
  after: {
    all: [populateAuthor, discard('authorId')]
  }
};