waibu 2.9.1 → 2.10.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/favicon.png ADDED
Binary file
package/index.js CHANGED
@@ -12,6 +12,7 @@ import handleError from './lib/handle-error.js'
12
12
  import handleNotFound from './lib/handle-not-found.js'
13
13
  import handleHome from './lib/handle-home.js'
14
14
  import queryString from 'query-string'
15
+ import decorate from './lib/decorate.js'
15
16
 
16
17
  /**
17
18
  * @typedef TEscapeChars
@@ -181,13 +182,8 @@ async function factory (pkgName) {
181
182
  cfg.factory.querystringParser = str => this.qs.parse(str)
182
183
 
183
184
  this.instance = fastify(cfg.factory)
184
- this.instance.decorateRequest('lang', null)
185
- this.instance.decorateRequest('t', () => {})
186
- this.instance.decorateRequest('format', () => {})
187
- this.instance.decorateRequest('langDetector', null)
188
- this.instance.decorateRequest('site', null)
189
- this.instance.decorateRequest('ns', null)
190
185
  this.routes = this.routes || []
186
+ await decorate.call(this)
191
187
  await runHook('waibu:afterCreateContext', this.instance)
192
188
  await this.instance.register(sensible)
193
189
  if (cfg.underPressure) await this.instance.register(underPressure)
@@ -0,0 +1,21 @@
1
+ async function decorate () {
2
+ const { get } = this.app.lib._
3
+ const { breakNsPath } = this.app.bajo
4
+ const me = this
5
+ this.instance.decorateRequest('lang', null)
6
+ this.instance.decorateRequest('t', () => {})
7
+ this.instance.decorateRequest('format', () => {})
8
+ this.instance.decorateRequest('langDetector', null)
9
+ this.instance.decorateRequest('site', null)
10
+ this.instance.decorateRequest('ns', null)
11
+ this.instance.decorateRequest('getSetting', function (key, defValue) {
12
+ let { ns, path } = breakNsPath(key)
13
+ const paths = path.replaceAll('/', '.').split('.')
14
+ if (paths[0] === '') paths.shift()
15
+ path = paths.join('.')
16
+ const cfgValue = get(me.app, `${ns}.config.${path}`, defValue)
17
+ return get(this, `site.setting.${ns}.${path}`, cfgValue)
18
+ })
19
+ }
20
+
21
+ export default decorate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.9.1",
3
+ "version": "2.10.0",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-11
4
+
5
+ - [2.10.0] Move all decorator to own file ```decorator.js```
6
+ - [2.10.0] Add new decorator ```req.getSetting()```
7
+
8
+ ## 2026-03-15
9
+
10
+ - [2.9.2] Bug fix missing default ```favicon.png```
11
+
3
12
  ## 2026-03-12
4
13
 
5
- - [2.9.1] Bug fix on ```req.body``` parsing with multipart body parser
14
+ - [2.9.1] Bug fix in ```req.body``` parsing with multipart body parser
6
15
 
7
16
  ## 2026-03-07
8
17
 
@@ -11,8 +20,8 @@
11
20
 
12
21
  ## 2026-03-06
13
22
 
14
- - [2.8.1] Bug fix on ```req.body``` parsing
15
- - [2.8.2] Bug fix on ```preValidation```
23
+ - [2.8.1] Bug fix in ```req.body``` parsing
24
+ - [2.8.2] Bug fix in ```preValidation```
16
25
 
17
26
  ## 2026-03-02
18
27
 
@@ -21,16 +30,16 @@
21
30
 
22
31
  ## 2026-02-21
23
32
 
24
- - [2.7.1] Bug fix on ```errorHandler```
25
- - [2.7.1] Bug fix on ```notFoundHandler```
33
+ - [2.7.1] Bug fix in ```errorHandler```
34
+ - [2.7.1] Bug fix in ```notFoundHandler```
26
35
  - [2.7.1] Add fallback template for both handlers above
27
36
 
28
37
 
29
38
  ## 2026-02-20
30
39
 
31
40
  - [2.7.0] Add ```req.te()``` decorator
32
- - [2.7.0] Bug fix on ```getPluginByPrefix()```
33
- - [2.7.0] Bug fix on ```notFoundHandler.interceptor()```
41
+ - [2.7.0] Bug fix in ```getPluginByPrefix()```
42
+ - [2.7.0] Bug fix in ```notFoundHandler.interceptor()```
34
43
 
35
44
  ## 2026-02-18
36
45
 
@@ -42,13 +51,13 @@
42
51
 
43
52
  ## 2026-02-16
44
53
 
45
- - [2.4.1] Bug fix on page with features
54
+ - [2.4.1] Bug fix in page with features
46
55
 
47
56
  ## 2026-02-09
48
57
 
49
- - [2.3.4] Bug fix on error handling
50
- - [2.3.4] Bug fix on not found handling
51
- - [2.3.4] Bug fix on redirection handling
58
+ - [2.3.4] Bug fix in error handling
59
+ - [2.3.4] Bug fix in not found handling
60
+ - [2.3.4] Bug fix in redirection handling
52
61
  - [2.4.0] Accept path parameter as in ```{param}``` to complement ```:param``` in ```routePath()```
53
62
 
54
63
  ## 2026-02-08
@@ -69,7 +78,7 @@
69
78
 
70
79
  ## 2026-01-19
71
80
 
72
- - [2.1.2] Bug fix on ```getAppTitle()```
81
+ - [2.1.2] Bug fix in ```getAppTitle()```
73
82
  - [2.1.2] Add missing some translation
74
83
 
75
84
  ## 2025-12-28