waibu 2.1.2 → 2.1.4

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
@@ -5,10 +5,10 @@ import routeHook from './lib/webapp-scope/route-hook.js'
5
5
  import printRoutes from './lib/print-routes.js'
6
6
  import { boot } from './lib/app.js'
7
7
  import sensible from '@fastify/sensible'
8
- import noIcon from 'fastify-no-icon'
9
8
  import underPressure from '@fastify/under-pressure'
10
9
  import handleForward from './lib/handle-forward.js'
11
10
  import handleRedirect from './lib/handle-redirect.js'
11
+ import handleFavicon from './lib/handle-favicon.js'
12
12
  import buildLocals from './lib/build-locals.js'
13
13
  import queryString from 'query-string'
14
14
 
@@ -117,7 +117,7 @@ async function factory (pkgName) {
117
117
  fileSize: 10485760
118
118
  }
119
119
  },
120
- noIcon: true,
120
+ favicon: false,
121
121
  underPressure: false,
122
122
  forwardOpts: {
123
123
  disableRequestLogging: true,
@@ -187,7 +187,7 @@ async function factory (pkgName) {
187
187
  await runHook('waibu:afterCreateContext', instance)
188
188
  await instance.register(sensible)
189
189
  if (cfg.underPressure) await instance.register(underPressure)
190
- if (cfg.noIcon) await instance.register(noIcon)
190
+ await handleFavicon.call(this, instance)
191
191
  await handleRedirect.call(this, instance)
192
192
  await handleForward.call(this, instance)
193
193
  await appHook.call(this)
@@ -443,7 +443,7 @@ async function factory (pkgName) {
443
443
  * @param {Object} [options.params={}] - Parameter object. If provided, it will be merged to returned value
444
444
  * @returns {string}
445
445
  */
446
- routePath = (name, options = {}) => {
446
+ routePath = (name = '', options = {}) => {
447
447
  const { getPlugin } = this.app.bajo
448
448
  const { defaultsDeep } = this.app.lib.aneka
449
449
  const { isEmpty, get, trimEnd, trimStart } = this.app.lib._
@@ -56,8 +56,7 @@ async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
56
56
  const { runHook } = this.app.bajo
57
57
  const { set, merge, pick, get, isEmpty, find, pullAt } = this.app.lib._
58
58
  const { req, reply } = opts
59
- const appTitle = this.app.waibuMpa ? req.t(this.app.waibuMpa.getAppTitle(req.ns)) : (req.ns ?? '')
60
- params.page = merge(params.page ?? {}, { ns: req.ns, appTitle })
59
+ params.page = merge(params.page ?? {}, { ns: req.ns })
61
60
  params.sidebar = params.sidebar ?? []
62
61
 
63
62
  const { site, user, lang, darkMode } = req
@@ -83,11 +82,7 @@ async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
83
82
  if (params.error) {
84
83
  if (params.error.statusCode) _meta.statusCode = params.error.statusCode
85
84
  _meta.errorMessage = params.error.message
86
- if (params.error.ns) {
87
- params.page.ns = params.error.ns
88
- params.page.appTitle = params.error.ns
89
- if (this.app.waibuMpa) params.page.appTitle = req.t(this.app.waibuMpa.getAppTitle(params.page.appTitle))
90
- }
85
+ if (params.error.ns) params.page.ns = params.error.ns
91
86
  if (!errs[req.id]) {
92
87
  this.log.error('error%s', params.error.message)
93
88
  if (this.app.bajo.config.env === 'dev') console.log(params.error)
@@ -0,0 +1,20 @@
1
+ import path from 'path'
2
+ import handleDownload from './handle-download.js'
3
+
4
+ async function handleFavicon (ctx) {
5
+ const { getPluginFile } = this.app.bajo
6
+ let file
7
+ let ext = '.ico'
8
+ if (this.config.favicon) {
9
+ file = getPluginFile(this.config.favicon === true ? 'main:/favicon.ico' : this.config.favicon)
10
+ ext = path.extname(file)
11
+ }
12
+ const me = this
13
+ ctx.get(`/favicon${ext}`, async function (req, reply) {
14
+ if (!file) return reply.code(404).send()
15
+ reply.header('cache-control', 'max-age=86400')
16
+ return await handleDownload.call(me, file, req, reply)
17
+ })
18
+ }
19
+
20
+ export default handleFavicon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -49,7 +49,6 @@
49
49
  "@fastify/session": "^11.1.1",
50
50
  "@fastify/under-pressure": "^9.0.3",
51
51
  "fastify": "^5.6.2",
52
- "fastify-no-icon": "^7.0.0",
53
52
  "query-string": "^9.3.1",
54
53
  "waibu-fastify-static": "^2.0.0"
55
54
  },
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-01-21
4
+
5
+ - [2.1.3] Rework on all title handlers
6
+ - [2.1.4] Faviocn handling
7
+
3
8
  ## 2026-01-19
4
9
 
5
10
  - [2.1.2] Bug fix on ```getAppTitle()```