waibu 2.9.0 → 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
@@ -12,7 +12,6 @@ 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 handleBody from './lib/handle-body.js'
16
15
 
17
16
  /**
18
17
  * @typedef TEscapeChars
@@ -197,7 +196,6 @@ async function factory (pkgName) {
197
196
  await handleAppHook.call(this)
198
197
  await handleError.call(this)
199
198
  await routeHook.call(this, this.ns)
200
- await handleBody.call(this)
201
199
  await webApp.call(this)
202
200
  await handleHome.call(this)
203
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.9.0",
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,9 @@
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
+
3
7
  ## 2026-03-07
4
8
 
5
9
  - [2.9.0] Change logo
@@ -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