Skip to content

Commit a35b26d

Browse files
committed
🎉 release: 1.2.25
1 parent cf45dba commit a35b26d

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 1.2.25 - 6 Mar 2025
22
Bug fix:
33
- [#1108](https://github.com/elysiajs/elysia/issues/1108) use validation response instead of return type when schema is provided
4+
- [#1105](https://github.com/elysiajs/elysia/pull/1105), [#1003](https://github.com/elysiajs/elysia/issues/1003) invalid parsing body with missed fields if used object model
45

56
# 1.2.24 - 2 Mar 2025
67
Bug fix:

example/a.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import { Elysia, error, t } from '../src'
22
import { req } from '../test/utils'
33

4-
const app = new Elysia().get(
5-
'/',
6-
() => {
7-
return {
8-
name: 'a',
9-
a: 'b'
4+
const app = new Elysia().mount(
5+
'/test',
6+
async (req) => new Response(await req.text())
7+
)
8+
9+
const testBody = JSON.stringify({ hello: 'world' })
10+
const response = await app.handle(
11+
new Request('http://localhost/test', {
12+
method: 'POST',
13+
body: testBody,
14+
headers: {
15+
'Content-Type': 'application/json'
1016
}
11-
},
12-
{
13-
response: t.Object({
14-
name: t.String()
15-
})
16-
}
17+
})
1718
)
1819

19-
app.handle(req('/'))
20-
.then((x) => x.json())
21-
.then(console.log)
20+
const responseBody = await response.text()
21+
console.log(responseBody)
22+
console.log(response.status)
23+
// expect(response.status).toBe(200)
24+
// expect(responseBody).toBe(testBody)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elysia",
33
"description": "Ergonomic Framework for Human",
4-
"version": "1.2.24",
4+
"version": "1.2.25",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",

src/compose.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,11 +1440,13 @@ export const composeHandler = ({
14401440
? `'${value}'`
14411441
: value
14421442

1443-
fnLiteral +=
1444-
`if(validator.body.Check(c.body)===false){` +
1445-
`if(typeof c.body==='object')` +
1446-
`c.body=Object.assign(${parsed},c.body)\n` +
1447-
`else c.body=${parsed}\n`
1443+
fnLiteral += `if(validator.body.Check(c.body)===false){`
1444+
1445+
if (value !== undefined && value !== null)
1446+
fnLiteral +=
1447+
`if(typeof c.body==='object')` +
1448+
`c.body=Object.assign(${parsed},c.body)\n` +
1449+
`else c.body=${parsed}\n`
14481450

14491451
if (isOptional(validator.body))
14501452
fnLiteral +=

0 commit comments

Comments
 (0)