Skip to content

Commit a27b433

Browse files
authored
Merge pull request #1403 from elysiajs/next
1.4.5 patch
2 parents 5bd3d7e + a964826 commit a27b433

File tree

15 files changed

+848
-323
lines changed

15 files changed

+848
-323
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 1.4.5 - 15 Sep 2025
2+
Improvement:
3+
- soundness for guard, group
4+
- overwrite primitive value if collide (intersectIfObject)
5+
6+
Bug fix:
7+
- standard schema incorrectly validate cookie and coercion
8+
- merge nested guard, group standalone schema properly
9+
10+
Breaking Change:
11+
- no longer coerce type for .model with `t.Ref` by default
12+
113
# 1.4.4 - 13 Sep 2025
214
Bug fix:
315
- merge schema in GET method

example/a.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { Elysia } from '../src'
1+
import { Elysia, t } from '../src'
22
import z from 'zod'
3-
import * as v from 'valibot'
3+
import { req } from '../test/utils'
44

5-
new Elysia()
6-
.guard({
7-
schema: 'standalone',
8-
body: z.object({
9-
id: z.coerce.number()
10-
})
5+
const app = new Elysia()
6+
.macro('guestOrUser', {
7+
resolve: () => {
8+
return {
9+
user: null
10+
}
11+
}
1112
})
12-
.get('/user/:id', ({ body }) => body, {
13-
body: v.object({
14-
name: v.literal('lilith')
15-
})
13+
.macro('user', {
14+
guestOrUser: true,
15+
body: t.String(),
16+
resolve: ({ body, status, user }) => {}
1617
})

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.4.4",
4+
"version": "1.4.5",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",

src/compose.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ export const composeHandler = ({
15041504
)
15051505

15061506
fnLiteral +=
1507-
`const cookieValue={}\n` +
1507+
`let cookieValue={}\n` +
15081508
`for(const [key,value] of Object.entries(c.cookie))` +
15091509
`cookieValue[key]=value.value\n`
15101510

@@ -1513,25 +1513,29 @@ export const composeHandler = ({
15131513

15141514
if (validator.cookie.provider === 'standard') {
15151515
fnLiteral +=
1516-
`let vac=validator.cookie.Check(c.body)\n` +
1516+
`let vac=validator.cookie.Check(cookieValue)\n` +
15171517
`if(vac instanceof Promise)vac=await vac\n` +
15181518
`if(vac.issues){` +
15191519
validation.validate('cookie', undefined, 'vac.issues') +
1520-
'}else{c.body=vac.value}\n'
1520+
'}else{cookieValue=vac.value}\n'
1521+
1522+
fnLiteral +=
1523+
`for(const k of Object.keys(cookieValue))` +
1524+
`c.cookie[k].value=cookieValue[k]\n`
15211525
} else if (validator.body?.schema?.noValidate !== true) {
15221526
fnLiteral +=
15231527
`if(validator.cookie.Check(cookieValue)===false){` +
15241528
validation.validate('cookie', 'cookieValue') +
15251529
'}'
1526-
}
15271530

1528-
// if (validator.cookie.hasTransform)
1529-
// fnLiteral += coerceTransformDecodeError(
1530-
// `for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue))){` +
1531-
// `c.cookie[key].value=value` +
1532-
// `}`,
1533-
// 'cookie'
1534-
// )
1531+
if (validator.cookie.hasTransform)
1532+
fnLiteral += coerceTransformDecodeError(
1533+
`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue))){` +
1534+
`c.cookie[key].value=value` +
1535+
`}`,
1536+
'cookie'
1537+
)
1538+
}
15351539

15361540
if (validator.cookie.isOptional) fnLiteral += `}`
15371541
}

0 commit comments

Comments
 (0)