aboutsummaryrefslogtreecommitdiff
path: root/services/feedback/feedback.hooks.ts
blob: 5bc25527f2fb4b23c0d89baa974966f7018bc5db (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
28
29
30
import { populate, discard, disallow } 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,
    remove: disallow('external'),
    patch: disallow('external'),
    update: disallow('external')
  },
  after: {
    all: [populateAuthor, discard('authorId')]
  }
};