waibu 2.11.0 → 2.11.2

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 CHANGED
@@ -582,13 +582,16 @@ async function factory (pkgName) {
582
582
 
583
583
  getSetting = (key, { defValue, req = {} } = {}) => {
584
584
  const { breakNsPath } = this.app.bajo
585
- const { get } = this.app.lib._
585
+ const { get, isPlainObject, isArray } = this.app.lib._
586
+ const { defaultsDeep } = this.app.lib.aneka
586
587
  let { ns, path } = breakNsPath(key)
587
588
  const paths = path.replaceAll('/', '.').split('.')
588
589
  if (paths[0] === '') paths.shift()
589
590
  path = paths.join('.')
590
- const cfgValue = get(this.app, `${ns}.config.${path}`, defValue)
591
- return get(req, `site.setting.${ns}.${path}`, cfgValue)
591
+ const cfgValue = get(this.app, `${ns}.config.${path}`)
592
+ const reqValue = get(req, `site.setting.${ns}.${path}`)
593
+ if (isPlainObject(cfgValue) || isArray(cfgValue)) return defaultsDeep({}, reqValue, cfgValue, defValue)
594
+ return reqValue ?? cfgValue ?? defValue
592
595
  }
593
596
  }
594
597
 
package/lib/decorate.js CHANGED
@@ -1,4 +1,6 @@
1
1
  async function decorate () {
2
+ const { isPlainObject, isArray } = this.app.lib._
3
+ const { defaultsDeep } = this.app.lib.aneka
2
4
  const me = this
3
5
  this.instance.decorateRequest('lang', null)
4
6
  this.instance.decorateRequest('t', () => {})
@@ -7,7 +9,9 @@ async function decorate () {
7
9
  this.instance.decorateRequest('site', null)
8
10
  this.instance.decorateRequest('ns', null)
9
11
  this.instance.decorateRequest('getSetting', function (key, defValue) {
10
- return me.app.waibu.getSetting(key, { defValue, req: this })
12
+ const value = me.app.waibu.getSetting(key, { req: this })
13
+ if (isPlainObject(value) || isArray(value)) return defaultsDeep({}, value, defValue)
14
+ return value ?? defValue
11
15
  })
12
16
  }
13
17
 
@@ -64,6 +64,7 @@ export async function notFound (err, req, reply) {
64
64
  reply.code(404)
65
65
  const resp = await interceptor.call(this, 'notFoundHandler', err, req, reply)
66
66
  if (resp) return resp
67
+ if (err.noContent) return ''
67
68
  const payload = {
68
69
  text: req.t('notFound%s%s', req.t('route'), req.url),
69
70
  title: req.t('pageNotFound')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-03
4
+
5
+ - [2.11.2] Bug fix in ```handle-not-found.js```
6
+
7
+ ## 2026-04-19
8
+
9
+ - [2.11.1] Bug fix in ```getSetting()```
10
+ - [2.11.1] Bug fix in ```decorate.js```
11
+
3
12
  ## 2026-04-13
4
13
 
5
14
  - [2.11.0] Add ```getSetting()```