waibu-rest-api 2.5.1 → 2.6.1

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.
@@ -22,7 +22,8 @@ async function routeByModelBuilder ({ file, dir, pathPrefix, ns, parent }) {
22
22
  if (disabled) continue
23
23
  const mod = omit(builder, ['model', 'url', 'method', 'handler', 'hidden', ...methods])
24
24
  const customMod = builder[method] ?? {}
25
- if (!customMod.schema) customMod.schema = await this.docSchemaModel({ model: builder.model, method, options: { hidden: builder.hidden } })
25
+ customMod.schema = customMod.schema ?? false
26
+ if (customMod.schema === true) customMod.schema = await this.docSchemaModel({ model: builder.model, method, options: { hidden: builder.hidden } })
26
27
  let mapmethod = methodMap[method]
27
28
  if (this.config.enablePatch) {
28
29
  if (method === 'replace') mapmethod = 'PUT'
@@ -44,14 +45,14 @@ async function routeByModelBuilder ({ file, dir, pathPrefix, ns, parent }) {
44
45
  options.queryHandler = builder.queryHandler
45
46
  if (method === 'replace') options.partial = false
46
47
  if (['get', 'remove', 'update'].includes(method)) options.throwNotFound = true
47
- const data = await helper({ model: builder.model, req, reply, options })
48
+ const data = await helper({ model: builder.model, req, reply, options, transaction: builder.transaction })
48
49
  data.success = true
49
50
  data.statusCode = method === 'create' ? 201 : 200
50
51
  if (method === 'find') options.forFind = true
51
52
  return me.transformResult({ data, req, reply, options })
52
53
  }
53
54
  })
54
- if (builder.schema === false) delete mod.schema
55
+ if (mod.schema === false) delete mod.schema
55
56
  mod.config = mod.config ?? {}
56
57
  mod.config.pathSrc = url
57
58
  mods.push(await serveRoute.call(me, { mod, ns, parent }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-rest-api",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
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-03-06
4
+
5
+ - [2.6.1] Bug fix on schema enforcement. Only apply when it's stated explicitely in route handler
6
+
7
+ ## 2026-03-05
8
+
9
+ - [2.6.0] Add transaction support by setting property ```transaction: true``` on model's route handler definition
10
+
3
11
  ## 2026-02-23
4
12
 
5
13
  - [2.5.1] Bug fix on ```transformResult()```