waibu-rest-api 2.5.0 → 2.6.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/index.js +2 -1
- package/lib/route-by-model-builder.js +1 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +8 -0
package/index.js
CHANGED
|
@@ -108,8 +108,9 @@ async function factory (pkgName) {
|
|
|
108
108
|
const { forOwn, get } = this.app.lib._
|
|
109
109
|
const newData = {}
|
|
110
110
|
forOwn(data, (v, k) => {
|
|
111
|
-
let key = get(this.config, `responseKey.${k}
|
|
111
|
+
let key = get(this.config, `responseKey.${k}`)
|
|
112
112
|
if (options.forFind && k === 'data') key = get(this.config, 'responseKey.data')
|
|
113
|
+
if (!key) return undefined
|
|
113
114
|
newData[key] = v
|
|
114
115
|
})
|
|
115
116
|
return newData
|
|
@@ -44,7 +44,7 @@ async function routeByModelBuilder ({ file, dir, pathPrefix, ns, parent }) {
|
|
|
44
44
|
options.queryHandler = builder.queryHandler
|
|
45
45
|
if (method === 'replace') options.partial = false
|
|
46
46
|
if (['get', 'remove', 'update'].includes(method)) options.throwNotFound = true
|
|
47
|
-
const data = await helper({ model: builder.model, req, reply, options })
|
|
47
|
+
const data = await helper({ model: builder.model, req, reply, options, transaction: builder.transaction })
|
|
48
48
|
data.success = true
|
|
49
49
|
data.statusCode = method === 'create' ? 201 : 200
|
|
50
50
|
if (method === 'find') options.forFind = true
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-05
|
|
4
|
+
|
|
5
|
+
- [2.6.0] Add transaction support by setting property ```transaction: true``` on model's route handler definition
|
|
6
|
+
|
|
7
|
+
## 2026-02-23
|
|
8
|
+
|
|
9
|
+
- [2.5.1] Bug fix on ```transformResult()```
|
|
10
|
+
|
|
3
11
|
## 2026-02-22
|
|
4
12
|
|
|
5
13
|
- [2.5.0] Add warnings to the response objects
|