waibu 2.8.2 → 2.9.1

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
@@ -8,12 +8,10 @@ import sensible from '@fastify/sensible'
8
8
  import underPressure from '@fastify/under-pressure'
9
9
  import handleForward from './lib/handle-forward.js'
10
10
  import handleRedirect from './lib/handle-redirect.js'
11
- import handleFavicon from './lib/handle-favicon.js'
12
11
  import handleError from './lib/handle-error.js'
13
12
  import handleNotFound from './lib/handle-not-found.js'
14
13
  import handleHome from './lib/handle-home.js'
15
14
  import queryString from 'query-string'
16
- import handleBody from './lib/handle-body.js'
17
15
 
18
16
  /**
19
17
  * @typedef TEscapeChars
@@ -125,7 +123,6 @@ async function factory (pkgName) {
125
123
  fileSize: 10485760
126
124
  }
127
125
  },
128
- favicon: false,
129
126
  underPressure: false,
130
127
  forwardOpts: {
131
128
  disableRequestLogging: true,
@@ -194,13 +191,11 @@ async function factory (pkgName) {
194
191
  await runHook('waibu:afterCreateContext', this.instance)
195
192
  await this.instance.register(sensible)
196
193
  if (cfg.underPressure) await this.instance.register(underPressure)
197
- await handleFavicon.call(this)
198
194
  await handleRedirect.call(this)
199
195
  await handleForward.call(this)
200
196
  await handleAppHook.call(this)
201
197
  await handleError.call(this)
202
198
  await routeHook.call(this, this.ns)
203
- await handleBody.call(this)
204
199
  await webApp.call(this)
205
200
  await handleHome.call(this)
206
201
  await handleNotFound.call(this)
@@ -1,10 +1,17 @@
1
1
  import multipart from '@fastify/multipart'
2
2
  import { promisify } from 'util'
3
3
  import { pipeline } from 'stream'
4
- import { normalizeValue } from '../handle-body.js'
5
4
  import path from 'path'
6
5
  const pump = promisify(pipeline)
7
6
 
7
+ function normalizeValue (value) {
8
+ const { isSet } = this.app.lib.aneka
9
+ if (!isSet(value)) return
10
+ if (value === 'null') value = null
11
+ else if (value === 'undefined') value = undefined
12
+ return value
13
+ }
14
+
8
15
  async function onFileHandler () {
9
16
  const { getPluginDataDir } = this.app.bajo
10
17
  const { fs } = this.app.lib
package/logo.png CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.8.2",
3
+ "version": "2.9.1",
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-03-12
4
+
5
+ - [2.9.1] Bug fix on ```req.body``` parsing with multipart body parser
6
+
7
+ ## 2026-03-07
8
+
9
+ - [2.9.0] Change logo
10
+ - [2.9.0] Remove favicon handler
11
+
3
12
  ## 2026-03-06
4
13
 
5
14
  - [2.8.1] Bug fix on ```req.body``` parsing
@@ -1,33 +0,0 @@
1
- export function normalizeValue (value) {
2
- const { isSet } = this.app.lib.aneka
3
- const { isArray, trim, isPlainObject } = this.app.lib._
4
- if (!isSet(value)) return
5
- if (value === 'null') value = null
6
- else if (value === 'undefined') value = undefined
7
- else {
8
- const val = trim(value)
9
- if (['{', '['].includes(val[0])) {
10
- try {
11
- const parsed = JSON.parse(val)
12
- if (isPlainObject(parsed) || isArray(parsed)) value = parsed
13
- } catch (err) {
14
- value = val
15
- }
16
- } else value = val
17
- }
18
- return value
19
- }
20
-
21
- async function handleBody (options = {}) {
22
- const { isPlainObject } = this.app.lib._
23
- const me = this
24
- this.instance.addHook('preValidation', async function (req, reply) {
25
- if (req.body && isPlainObject(req.body)) {
26
- for (const key in req.body) {
27
- req.body[key] = normalizeValue.call(me, req.body[key])
28
- }
29
- }
30
- })
31
- }
32
-
33
- export default handleBody
@@ -1,20 +0,0 @@
1
- import path from 'path'
2
- import handleDownload from './handle-download.js'
3
-
4
- async function handleFavicon () {
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
- this.instance.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