Skip to content

Commit 935efe2

Browse files
authored
Merge pull request #1657 from elysiajs/next
patch: 1.4.22
2 parents 8c42013 + 131a452 commit 935efe2

File tree

15 files changed

+172
-106
lines changed

15 files changed

+172
-106
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 1.4.22 - 14 Jan 2026
2+
Improvement:
3+
- use imperative check for `replaceURLPath` instead of allocating `new URL`
4+
- reduce ts-ignore/ts-expect-error on promise map handler
5+
6+
Bug fix:
7+
- [#1671](https://github.com/elysiajs/elysia/issues/1671) mount produces incorrect URL path when Elysia instance has prefix option
8+
- [https://github.com/elysiajs/elysia/issues/1617](https://github.com/elysiajs/elysia/issues/1617), [#1623](https://github.com/elysiajs/elysia/pull/1623) AOT compilation removes beforeHandle when using arrow function expression
9+
- [#1667](https://github.com/elysiajs/elysia/issues/1667) skip body parsing on mount with dynamic mode
10+
- [#1662](https://github.com/elysiajs/elysia/pull/1662) custom thenable fallback in `mapCompactResponse` causing runtime crash with undefined variable
11+
- [#1661](https://github.com/elysiajs/elysia/pull/1661), [#1663](https://github.com/elysiajs/elysia/pull/1663) fix SSE double-wrapping bug when returning pre-formatted Response
12+
- ValueError with summary missing types
13+
- Elysia not using Bun.routes by default
14+
115
# 1.4.21 - 4 Jan 2026
216
Improvement:
317
- [#1654](https://github.com/elysiajs/elysia/pull/1654) encode t.Date() to iso string

example/a.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { Elysia, t } from '../src'
2-
import { z } from 'zod'
3-
import { req } from '../test/utils'
1+
import { Elysia } from '../src'
42

5-
export const app = new Elysia()
6-
.ws('/', {
7-
open(ws) {
8-
ws.subscribe('a')
9-
},
10-
message(a) {
11-
console.log(a.subscriptions)
12-
}
13-
})
14-
.listen(3000)
3+
new Elysia()
4+
.post(
5+
"/create-post",
6+
async (ctx) => {
7+
return {
8+
message: "Post Created",
9+
data: ctx.body,
10+
};
11+
},
12+
{
13+
body: t.Object({
14+
name: t.String(),
15+
content: t.String(),
16+
safeAge: t.Number(),
17+
}),
18+
},

example/newFile.ts

Whitespace-only changes.

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

src/adapter/bun/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const createContext = (
3333
const getQi =
3434
`const u=request.url,` +
3535
`s=u.indexOf('/',${standardHostname ? 11 : 7}),` +
36-
`qi=u.indexOf('?', s + 1)\n`
36+
`qi=u.indexOf('?',s+1)\n`
3737

3838
const needsQuery =
3939
inference.query ||

src/adapter/bun/handler.ts

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ export const mapResponse = (
3737
return new Response(JSON.stringify(response), set as any)
3838

3939
case 'ElysiaFile':
40-
return handleFile(
41-
(response as ElysiaFile).value as File,
42-
set
43-
)
40+
return handleFile((response as ElysiaFile).value as File, set)
4441

4542
case 'File':
4643
return handleFile(response as File, set)
@@ -122,10 +119,8 @@ export const mapResponse = (
122119
)
123120
return handleStream(response as any, set, request) as any
124121

125-
// @ts-expect-error
126-
if (typeof response?.then === 'function')
127-
// @ts-expect-error
128-
return response.then((x) => mapResponse(x, set)) as any
122+
if (typeof (response as Promise<unknown>)?.then === 'function')
123+
return (response as Promise<unknown>).then((x) => mapResponse(x, set)) as any
129124

130125
// @ts-expect-error
131126
if (typeof response?.toResponse === 'function')
@@ -206,10 +201,9 @@ export const mapEarlyResponse = (
206201
return handleResponse(response as Response, set, request)
207202

208203
case 'Promise':
209-
// @ts-ignore
210204
return (response as Promise<unknown>).then((x) =>
211205
mapEarlyResponse(x, set)
212-
)
206+
) as any
213207

214208
case 'Error':
215209
return errorToResponse(response as Error, set)
@@ -262,10 +256,10 @@ export const mapEarlyResponse = (
262256
)
263257
return handleStream(response as any, set, request) as any
264258

265-
// @ts-expect-error
266-
if (typeof response?.then === 'function')
267-
// @ts-expect-error
268-
return response.then((x) => mapEarlyResponse(x, set)) as any
259+
if (typeof (response as Promise<unknown>)?.then === 'function')
260+
return (response as Promise<unknown>).then((x) =>
261+
mapEarlyResponse(x, set)
262+
) as any
269263

270264
// @ts-expect-error
271265
if (typeof response?.toResponse === 'function')
@@ -328,11 +322,10 @@ export const mapEarlyResponse = (
328322
return response as Response
329323

330324
case 'Promise':
331-
// @ts-ignore
332325
return (response as Promise<unknown>).then((x) => {
333326
const r = mapEarlyResponse(x, set)
334327
if (r !== undefined) return r
335-
})
328+
}) as any
336329

337330
case 'Error':
338331
return errorToResponse(response as Error, set)
@@ -381,10 +374,10 @@ export const mapEarlyResponse = (
381374
)
382375
return handleStream(response as any, set, request) as any
383376

384-
// @ts-expect-error
385-
if (typeof response?.then === 'function')
386-
// @ts-expect-error
387-
return response.then((x) => mapEarlyResponse(x, set)) as any
377+
if (typeof (response as Promise<unknown>)?.then === 'function')
378+
return (response as Promise<unknown>).then((x) =>
379+
mapEarlyResponse(x, set)
380+
) as any
388381

389382
// @ts-expect-error
390383
if (typeof response?.toResponse === 'function')
@@ -458,7 +451,7 @@ export const mapCompactResponse = (
458451
return errorToResponse(response as Error)
459452

460453
case 'Promise':
461-
return (response as any as Promise<unknown>).then((x) =>
454+
return (response as Promise<unknown>).then((x) =>
462455
mapCompactResponse(x, request)
463456
) as any
464457

@@ -501,12 +494,12 @@ export const mapCompactResponse = (
501494
)
502495
return handleStream(response as any, undefined, request) as any
503496

504-
// @ts-expect-error
505-
if (typeof response?.then === 'function')
506-
// @ts-expect-error
507-
return response.then((x) => mapCompactResponse(x, request)) as any
497+
if (typeof (response as Promise<unknown>)?.then === 'function')
498+
return (response as Promise<unknown>).then((x) =>
499+
mapCompactResponse(x, request)
500+
) as any
508501

509-
// @ts-expect-error
502+
// @ts-expect-errors
510503
if (typeof response?.toResponse === 'function')
511504
return mapCompactResponse((response as any).toResponse())
512505

@@ -532,15 +525,14 @@ export const errorToResponse = (error: Error, set?: Context['set']) => {
532525
// @ts-expect-error
533526
const raw = error.toResponse()
534527
const targetSet =
535-
set ?? ({ headers: {}, status: 200, redirect: '' } as Context['set'])
528+
set ??
529+
({ headers: {}, status: 200, redirect: '' } as Context['set'])
536530
const apply = (resolved: unknown) => {
537531
if (resolved instanceof Response) targetSet.status = resolved.status
538532
return mapResponse(resolved, targetSet)
539533
}
540534

541-
return typeof raw?.then === 'function'
542-
? raw.then(apply)
543-
: apply(raw)
535+
return typeof raw?.then === 'function' ? raw.then(apply) : apply(raw)
544536
}
545537

546538
return new Response(

src/adapter/bun/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const supportedMethods = {
8484
} as const
8585

8686
const mapRoutes = (app: AnyElysia) => {
87-
if (!app.config.aot || !app.config.systemRouter) return undefined
87+
if (!app.config.aot || app.config.systemRouter === false) return undefined
8888

8989
const routes = <Record<string, Function | Record<string, unknown>>>{}
9090

src/adapter/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const responseToSetHeaders = (
136136
return set
137137
}
138138

139-
type CreateHandlerParameter = {
139+
interface CreateHandlerParameter {
140140
mapResponse(
141141
response: unknown,
142142
set: Context['set'],

src/adapter/web-standard/handler.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Cookie } from '../../cookies'
1313
import { ElysiaCustomStatusResponse } from '../../error'
1414

1515
import type { Context } from '../../context'
16-
import type { AnyLocalHook } from '../../types'
16+
import type { AnyLocalHook, MaybePromise } from '../../types'
1717

1818
const handleElysiaFile = (
1919
file: ElysiaFile,
@@ -149,10 +149,10 @@ export const mapResponse = (
149149
)
150150
return handleStream(response as any, set, request) as any
151151

152-
// @ts-expect-error
153-
if (typeof response?.then === 'function')
154-
// @ts-expect-error
155-
return response.then((x) => mapResponse(x, set)) as any
152+
if (typeof (response as Promise<unknown>)?.then === 'function')
153+
return (response as Promise<unknown>).then((x) =>
154+
mapResponse(x, set)
155+
) as any
156156

157157
// @ts-expect-error
158158
if (typeof response?.toResponse === 'function')
@@ -234,10 +234,9 @@ export const mapEarlyResponse = (
234234
return handleResponse(response as Response, set, request)
235235

236236
case 'Promise':
237-
// @ts-ignore
238237
return (response as Promise<unknown>).then((x) =>
239238
mapEarlyResponse(x, set)
240-
)
239+
) as any
241240

242241
case 'Error':
243242
return errorToResponse(response as Error, set)
@@ -290,10 +289,10 @@ export const mapEarlyResponse = (
290289
)
291290
return handleStream(response as any, set, request) as any
292291

293-
// @ts-expect-error
294-
if (typeof response?.then === 'function')
295-
// @ts-expect-error
296-
return response.then((x) => mapEarlyResponse(x, set)) as any
292+
if (typeof (response as Promise<unknown>)?.then === 'function')
293+
return (response as Promise<unknown>).then((x) =>
294+
mapEarlyResponse(x, set)
295+
) as any
297296

298297
// @ts-expect-error
299298
if (typeof response?.toResponse === 'function')
@@ -357,11 +356,10 @@ export const mapEarlyResponse = (
357356
return response as Response
358357

359358
case 'Promise':
360-
// @ts-ignore
361359
return (response as Promise<unknown>).then((x) => {
362360
const r = mapEarlyResponse(x, set)
363361
if (r !== undefined) return r
364-
})
362+
}) as any
365363

366364
case 'Error':
367365
return errorToResponse(response as Error, set)
@@ -410,10 +408,10 @@ export const mapEarlyResponse = (
410408
)
411409
return handleStream(response as any, set, request) as any
412410

413-
// @ts-expect-error
414-
if (typeof response?.then === 'function')
415-
// @ts-expect-error
416-
return response.then((x) => mapEarlyResponse(x, set)) as any
411+
if (typeof (response as Promise<unknown>)?.then === 'function')
412+
return (response as Promise<unknown>).then((x) =>
413+
mapEarlyResponse(x, set)
414+
) as any
417415

418416
// @ts-expect-error
419417
if (typeof response?.toResponse === 'function')
@@ -534,10 +532,10 @@ export const mapCompactResponse = (
534532
)
535533
return handleStream(response as any, undefined, request) as any
536534

537-
// @ts-expect-error
538-
if (typeof response?.then === 'function')
539-
// @ts-expect-error
540-
return response.then((x) => mapCompactResponse(x, request)) as any
535+
if (typeof (response as Promise<unknown>)?.then === 'function')
536+
return (response as Promise<unknown>).then((x) =>
537+
mapCompactResponse(x, request)
538+
) as any
541539

542540
// @ts-expect-error
543541
if (typeof response?.toResponse === 'function')
@@ -559,21 +557,23 @@ export const mapCompactResponse = (
559557
}
560558
}
561559

562-
export const errorToResponse = (error: Error, set?: Context['set']) => {
563-
// @ts-expect-error
560+
export const errorToResponse = (
561+
error: Error & { toResponse?(): MaybePromise<Response> },
562+
set?: Context['set']
563+
) => {
564564
if (typeof error?.toResponse === 'function') {
565-
// @ts-expect-error
566565
const raw = error.toResponse()
567566
const targetSet =
568-
set ?? ({ headers: {}, status: 200, redirect: '' } as Context['set'])
567+
set ??
568+
({ headers: {}, status: 200, redirect: '' } as Context['set'])
569+
569570
const apply = (resolved: unknown) => {
570571
if (resolved instanceof Response) targetSet.status = resolved.status
571572
return mapResponse(resolved, targetSet)
572573
}
573574

574-
return typeof raw?.then === 'function'
575-
? raw.then(apply)
576-
: apply(raw)
575+
// @ts-ignore
576+
return typeof raw?.then === 'function' ? raw.then(apply) : apply(raw)
577577
}
578578

579579
return new Response(

src/compose.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { AnyElysia, Cookie } from './index'
33
import { Value, TransformDecodeError } from '@sinclair/typebox/value'
44
import {
55
Kind,
6-
OptionalKind,
76
TypeBoxError,
87
type TAnySchema,
98
type TSchema
@@ -372,11 +371,9 @@ const matchFnReturn = /(?:return|=>)\s?\S+\(|a(?:sync|wait)/
372371

373372
export const isAsync = (v: Function | HookContainer) => {
374373
const isObject = typeof v === 'object'
375-
376374
if (isObject && v.isAsync !== undefined) return v.isAsync
377375

378376
const fn = isObject ? v.fn : v
379-
380377
if (fn.constructor.name === 'AsyncFunction') return true
381378

382379
const literal: string = fn.toString()
@@ -388,7 +385,6 @@ export const isAsync = (v: Function | HookContainer) => {
388385
}
389386

390387
const result = matchFnReturn.test(literal)
391-
392388
if (isObject) v.isAsync = result
393389

394390
return result

0 commit comments

Comments
 (0)