waibu-rest-api 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/route-by-model-builder.js +4 -4
- package/lib/route-by-verb.js +4 -4
- package/package.json +1 -1
- package/wiki/CHANGES.md +8 -0
|
@@ -34,12 +34,12 @@ async function routeByModelBuilder ({ file, ctx, dir, pathPrefix, ns, parent })
|
|
|
34
34
|
handler: async function (req, reply) {
|
|
35
35
|
const helper = me.app.waibuDb[`${method === 'replace' ? 'update' : method}Record`]
|
|
36
36
|
let { fields, count } = getParams(req)
|
|
37
|
-
let
|
|
37
|
+
let refs = []
|
|
38
38
|
const headers = parseObject(req.headers, { parseValue: true })
|
|
39
39
|
if (isSet(headers['x-count'])) count = headers['x-count']
|
|
40
|
-
if (isSet(headers['x-
|
|
41
|
-
if (typeof
|
|
42
|
-
const options = { fields, count,
|
|
40
|
+
if (isSet(headers['x-refs'])) refs = headers['x-refs']
|
|
41
|
+
if (typeof refs === 'string' && !['*', 'all'].includes(refs)) refs = [refs]
|
|
42
|
+
const options = { fields, count, refs, dynHooks: builder.hooks ?? [] }
|
|
43
43
|
options.hidden = builder.hidden ?? []
|
|
44
44
|
options.queryHandler = builder.queryHandler
|
|
45
45
|
if (method === 'replace') options.partial = false
|
package/lib/route-by-verb.js
CHANGED
|
@@ -45,12 +45,12 @@ async function routeByVerb ({ file, ctx, appCtx, dir, pathPrefix, ns, alias, par
|
|
|
45
45
|
const oldHandler = mod.handler
|
|
46
46
|
mod.handler = async function (req, reply) {
|
|
47
47
|
let { fields, count } = getParams(req)
|
|
48
|
-
let
|
|
48
|
+
let refs = []
|
|
49
49
|
const headers = parseObject(req.headers, { parseValue: true })
|
|
50
50
|
if (isSet(headers['x-count'])) count = headers['x-count']
|
|
51
|
-
if (isSet(headers['x-
|
|
52
|
-
if (typeof
|
|
53
|
-
const options = { fields, count,
|
|
51
|
+
if (isSet(headers['x-refs'])) refs = headers['x-refs']
|
|
52
|
+
if (typeof refs === 'string' && !['*', 'all'].includes(refs)) refs = [refs]
|
|
53
|
+
const options = { fields, count, refs }
|
|
54
54
|
if (method === 'find') options.forFind = true
|
|
55
55
|
if (method === 'replace') options.partial = false
|
|
56
56
|
const data = await oldHandler.call(me.app[ns], req, reply, options, this)
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-01-24
|
|
4
|
+
|
|
5
|
+
- [2.2.0] Add ```hooks``` property to model builder that will be considered as dynamic hoooks by models
|
|
6
|
+
|
|
7
|
+
## 2026-01-16
|
|
8
|
+
|
|
9
|
+
- [2.1.1] Bug fix on model references
|
|
10
|
+
|
|
3
11
|
## 2025-12-28
|
|
4
12
|
|
|
5
13
|
- [2.1.0] Ported to ```bajo@2.2.x``` specs
|