summaryrefslogtreecommitdiff
path: root/src/services/transfers.service.ts
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-20 00:12:40 +0300
committereug-vs <eug-vs@keemail.me>2021-03-20 00:12:40 +0300
commitcd284d9e4c1f28bf7c31c52d71e76878a3ff5f4a (patch)
treeed6b97b4e9bc85c921869de004dfff8f5e2066dc /src/services/transfers.service.ts
parentad530510a4aba72f3074f1a7dec82cc9018db7b4 (diff)
downloadcommercel-api-cd284d9e4c1f28bf7c31c52d71e76878a3ff5f4a.tar.gz
feat: move formatDate to hooks
Diffstat (limited to 'src/services/transfers.service.ts')
-rw-r--r--src/services/transfers.service.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/services/transfers.service.ts b/src/services/transfers.service.ts
new file mode 100644
index 0000000..cf6a490
--- /dev/null
+++ b/src/services/transfers.service.ts
@@ -0,0 +1,32 @@
+import { Application } from '@feathersjs/express';
+import service from 'feathers-mongoose';
+import { populate } from 'feathers-hooks-common';
+import Model from '../models/transfer/transfer.model';
+import formatDate from '../hooks/formatDate';
+
+const transfers = service({ Model });
+
+const populateSchema = {
+ include: [
+ {
+ service: 'contractors',
+ nameAs: 'contractor',
+ parentField: 'contractorId',
+ childField: '_id'
+ }
+ ]
+};
+
+export default (app: Application): void => {
+ app.use('/transfers', transfers);
+
+ app.service('transfers').hooks({
+ after: {
+ all: [
+ populate({ schema: populateSchema }),
+ formatDate(),
+ ],
+ },
+ })
+};
+