aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-07-05 12:23:11 +0300
committereug-vs <eug-vs@keemail.me>2020-07-05 12:23:11 +0300
commitf38a1cf6a6809e85ac2ba47026c42b49bfee3673 (patch)
tree315646559fdca780d914246241f7fa2042927eb1
parentda76bb1bd8797c4e1dc657c489f597bf64918ceb (diff)
downloadwhich-api-f38a1cf6a6809e85ac2ba47026c42b49bfee3673.tar.gz
feat: upgrade feedback hooks
-rw-r--r--services/feedback/feedback.hooks.ts20
1 files changed, 19 insertions, 1 deletions
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')]
}
};