waibu-rest-api 2.11.0 → 2.12.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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
async function hook () {
|
|
2
|
+
return [{
|
|
3
|
+
level: 9,
|
|
4
|
+
name: 'waibuRestApi:preParsing',
|
|
5
|
+
handler: async function (req, reply) {
|
|
6
|
+
const { importModule } = this.app.bajo
|
|
7
|
+
const attachIntl = await importModule('waibu:/lib/webapp-scope/attach-intl.js')
|
|
8
|
+
await attachIntl.call(this, this.config.intl.detectors, req, reply)
|
|
9
|
+
reply.header('Content-Language', req.lang)
|
|
10
|
+
if (this.config.format.asExt && req.params.format) {
|
|
11
|
+
if (!this.config.format.supported.includes(req.params.format)) {
|
|
12
|
+
throw this.error('unsupportedFormat%s', req.params.format, { statusCode: 406 })
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
name: 'waibu:afterInit',
|
|
18
|
+
handler: async function () {
|
|
19
|
+
this.app.waibu.config.paramsCharMap[this.config.mapSlash] = '/'
|
|
20
|
+
// this.app.waibu.config.paramsCharMap[this.config.mapDot] = '.'
|
|
21
|
+
}
|
|
22
|
+
}]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default hook
|
package/index.js
CHANGED
|
@@ -106,7 +106,6 @@ async function factory (pkgName) {
|
|
|
106
106
|
|
|
107
107
|
transformResult = ({ data, req, reply, options = {} }) => {
|
|
108
108
|
const reformat = ({ data, req, reply, options = {} }) => {
|
|
109
|
-
// console.log(data)
|
|
110
109
|
const { forOwn, get } = this.app.lib._
|
|
111
110
|
const newData = {}
|
|
112
111
|
forOwn(data, (v, k) => {
|
package/lib/serve-route.js
CHANGED
|
@@ -11,7 +11,7 @@ async function serveRoute ({ mod, ns, parent }) {
|
|
|
11
11
|
mod.config.webApp = parent ?? ns
|
|
12
12
|
mod.config.ns = ns
|
|
13
13
|
mod.config.subNs = 'restapi'
|
|
14
|
-
mod.config.
|
|
14
|
+
mod.config.xSite = mod.xSite
|
|
15
15
|
mod.config.title = mod.title
|
|
16
16
|
delete mod.title
|
|
17
17
|
if (mod.method === 'PUT' && cfgWdb.dbModel.patchEnabled) mod.method = [mod.method, 'PATCH']
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-28
|
|
4
|
+
|
|
5
|
+
- [2.12.0] Change hooks to be written in one ```hook.js``` file
|
|
6
|
+
|
|
7
|
+
## 2026-05-22
|
|
8
|
+
|
|
9
|
+
- [2.11.1] Bug fix in ```serve-route.js```
|
|
10
|
+
|
|
3
11
|
## 2026-04-25
|
|
4
12
|
|
|
5
13
|
- [2.11.0] Change options to format value using the new key set by dobo
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const waibuRestApiPreParsing = {
|
|
2
|
-
level: 9,
|
|
3
|
-
handler: async function (req, reply) {
|
|
4
|
-
const { importModule } = this.app.bajo
|
|
5
|
-
const attachIntl = await importModule('waibu:/lib/webapp-scope/attach-intl.js')
|
|
6
|
-
await attachIntl.call(this, this.config.intl.detectors, req, reply)
|
|
7
|
-
reply.header('Content-Language', req.lang)
|
|
8
|
-
if (this.config.format.asExt && req.params.format) {
|
|
9
|
-
if (!this.config.format.supported.includes(req.params.format)) {
|
|
10
|
-
throw this.error('unsupportedFormat%s', req.params.format, { statusCode: 406 })
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default waibuRestApiPreParsing
|