summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-14 13:39:06 +0300
committereug-vs <eug-vs@keemail.me>2021-03-14 13:39:06 +0300
commit61939d8c23e72ddd995c9319577053fff5211184 (patch)
tree4e9f9f5934889f18edf526fcf7018dfe6316f7b7
parent3a2cdd13b0374aab279b8dd819b03f82013cb026 (diff)
downloadcommercel-api-61939d8c23e72ddd995c9319577053fff5211184.tar.gz
feat: populate Waybills
-rw-r--r--package.json1
-rw-r--r--src/services/waybills.service.ts23
-rw-r--r--yarn.lock73
3 files changed, 97 insertions, 0 deletions
diff --git a/package.json b/package.json
index f60c749..ef74095 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"@feathersjs/socketio": "^4.5.11",
"bluebird": "^3.7.2",
"cors": "^2.8.5",
+ "feathers-hooks-common": "^5.0.5",
"feathers-mongoose": "^8.3.1",
"mongoose": "^5.12.0"
},
diff --git a/src/services/waybills.service.ts b/src/services/waybills.service.ts
index 7aea1e3..0744bee 100644
--- a/src/services/waybills.service.ts
+++ b/src/services/waybills.service.ts
@@ -1,10 +1,33 @@
import { Application } from '@feathersjs/express';
import service from 'feathers-mongoose';
+import { populate } from 'feathers-hooks-common';
import Model from '../models/waybill/waybill.model';
const waybills = service({ Model });
+const populateSchema = {
+ include: [
+ {
+ service: 'contractors',
+ nameAs: 'contractor',
+ parentField: 'contractorId',
+ childField: '_id'
+ },
+ {
+ service: 'products',
+ nameAs: 'product',
+ parentField: 'productId',
+ childField: '_id'
+ },
+ ]
+};
+
export default (app: Application): void => {
app.use('/waybills', waybills);
+ app.service('waybills').hooks({
+ after: {
+ all: populate({ schema: populateSchema }),
+ },
+ })
};
diff --git a/yarn.lock b/yarn.lock
index 0a638b6..e7be360 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,6 +2,11 @@
# yarn lockfile v1
+"@feathers-plus/batch-loader@^0.3.6":
+ version "0.3.6"
+ resolved "https://registry.yarnpkg.com/@feathers-plus/batch-loader/-/batch-loader-0.3.6.tgz#1e096e95fcdffb83fb1a65468e6ef80b416f7d98"
+ integrity sha512-r+n31iZ/B5Rl1mLkC9/S20UI445MdkZvE3VBmjupep2t8OuyTYHPkFEgR25HY6khH+RothK1VL3B5eumk9N2QQ==
+
"@feathersjs/adapter-commons@^4.4.3":
version "4.5.11"
resolved "https://registry.yarnpkg.com/@feathersjs/adapter-commons/-/adapter-commons-4.5.11.tgz#b7eaa9a9124591aa639f9080a7522fa60fb29915"
@@ -199,6 +204,16 @@ after@0.8.2:
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"
integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=
+ajv@^6.12.6:
+ version "6.12.6"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
+ integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
+ dependencies:
+ fast-deep-equal "^3.1.1"
+ fast-json-stable-stringify "^2.0.0"
+ json-schema-traverse "^0.4.1"
+ uri-js "^4.2.2"
+
array-flatten@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
@@ -477,6 +492,32 @@ express@^4.17.1:
utils-merge "1.0.1"
vary "~1.1.2"
+fast-deep-equal@^3.1.1:
+ version "3.1.3"
+ resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
+ integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
+
+fast-json-stable-stringify@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
+ integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
+
+feathers-hooks-common@^5.0.5:
+ version "5.0.5"
+ resolved "https://registry.yarnpkg.com/feathers-hooks-common/-/feathers-hooks-common-5.0.5.tgz#27f18b5aeccab62c42af78928a1eb168f1cfab35"
+ integrity sha512-GOHZ6W/ioEK5uCs4bCh21P/oLObVqIkbQ6WTKZMscJlykDptH3KOIMiUpFscO6uLQcKKZHY7a1PabLNFP2J7tA==
+ dependencies:
+ "@feathers-plus/batch-loader" "^0.3.6"
+ "@feathersjs/commons" "^4.5.11"
+ "@feathersjs/errors" "^4.5.11"
+ "@feathersjs/feathers" "^4.5.11"
+ ajv "^6.12.6"
+ debug "^4.3.1"
+ graphql "^15.5.0"
+ lodash "^4.17.20"
+ process "0.11.10"
+ traverse "^0.6.6"
+
feathers-mongoose@^8.3.1:
version "8.3.1"
resolved "https://registry.yarnpkg.com/feathers-mongoose/-/feathers-mongoose-8.3.1.tgz#240ecb746e1da26e05fb85d16148c84ec41f8a80"
@@ -509,6 +550,11 @@ fresh@0.5.2:
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=
+graphql@^15.5.0:
+ version "15.5.0"
+ resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.0.tgz#39d19494dbe69d1ea719915b578bf920344a69d5"
+ integrity sha512-OmaM7y0kaK31NKG31q4YbD2beNYa6jBBKtMFT6gLYJljHLJr42IqJ8KX08u3Li/0ifzTU5HjmoOOrwa5BRLeDA==
+
has-binary2@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d"
@@ -580,6 +626,11 @@ isarray@~1.0.0:
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
+json-schema-traverse@^0.4.1:
+ version "0.4.1"
+ resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
+ integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
+
kareem@2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.2.tgz#78c4508894985b8d38a0dc15e1a8e11078f2ca93"
@@ -741,6 +792,11 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
+process@0.11.10:
+ version "0.11.10"
+ resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
+ integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
+
proxy-addr@~2.0.5:
version "2.0.6"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"
@@ -749,6 +805,11 @@ proxy-addr@~2.0.5:
forwarded "~0.1.2"
ipaddr.js "1.9.1"
+punycode@^2.1.0:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
+ integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
+
qs@6.7.0:
version "6.7.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
@@ -957,6 +1018,11 @@ toidentifier@1.0.0:
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
+traverse@^0.6.6:
+ version "0.6.6"
+ resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137"
+ integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=
+
type-is@~1.6.17, type-is@~1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
@@ -975,6 +1041,13 @@ unpipe@1.0.0, unpipe@~1.0.0:
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=
+uri-js@^4.2.2:
+ version "4.4.1"
+ resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
+ integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
+ dependencies:
+ punycode "^2.1.0"
+
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"