From f38a1cf6a6809e85ac2ba47026c42b49bfee3673 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 5 Jul 2020 12:23:11 +0300 Subject: feat: upgrade feedback hooks --- services/feedback/feedback.hooks.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/services/feedback/feedback.hooks.ts b/services/feedback/feedback.hooks.ts index 56e9000..7ae6c5d 100644 --- a/services/feedback/feedback.hooks.ts +++ b/services/feedback/feedback.hooks.ts @@ -1,9 +1,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] + create: [requireAuth, signAuthority], + find: sortByDate + }, + after: { + all: [populateAuthor, discard('authorId')] } }; -- cgit v1.2.3