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.
@@ -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 rels = []
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-rels'])) rels = headers['x-rels']
41
- if (typeof rels === 'string' && !['*', 'all'].includes(rels)) rels = [rels]
42
- const options = { fields, count, rels }
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
@@ -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 rels = []
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-rels'])) rels = headers['x-rels']
52
- if (typeof rels === 'string' && !['*', 'all'].includes(rels)) rels = [rels]
53
- const options = { fields, count, rels }
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-rest-api",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "REST API for Waibu",
5
5
  "main": "index.js",
6
6
  "scripts": {
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