📘 doc: document changelog

This commit is contained in:
saltyaom
2026-01-14 11:33:45 +07:00
parent 7f8f55c04f
commit bc882d42dd
3 changed files with 52 additions and 58 deletions
+2
View File
@@ -1,11 +1,13 @@
# 1.4.22
Improvement:
- use imperative check for `replaceURLPath` instead of allocating `new URL`
- reduce ts-ignore/ts-expect-error on promise map handler
Bug fix:
- [#1671](https://github.com/elysiajs/elysia/issues/1671) mount produces incorrect URL path when Elysia instance has prefix option
- [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
- [#1667](https://github.com/elysiajs/elysia/issues/1667) skip body parsing on mount with dynamic mode
- [#1662](https://github.com/elysiajs/elysia/pull/1662) custom thenable fallback in `mapCompactResponse` causing runtime crash with undefined variable
- [#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
- ValueError with summary missing types
- Elysia not using Bun.routes by default
+22 -30
View File
@@ -37,10 +37,7 @@ export const mapResponse = (
return new Response(JSON.stringify(response), set as any)
case 'ElysiaFile':
return handleFile(
(response as ElysiaFile).value as File,
set
)
return handleFile((response as ElysiaFile).value as File, set)
case 'File':
return handleFile(response as File, set)
@@ -122,10 +119,8 @@ export const mapResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) => mapResponse(x, set)) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -206,10 +201,9 @@ export const mapEarlyResponse = (
return handleResponse(response as Response, set, request)
case 'Promise':
// @ts-ignore
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
)
) as any
case 'Error':
return errorToResponse(response as Error, set)
@@ -262,10 +256,10 @@ export const mapEarlyResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapEarlyResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -328,11 +322,10 @@ export const mapEarlyResponse = (
return response as Response
case 'Promise':
// @ts-ignore
return (response as Promise<unknown>).then((x) => {
const r = mapEarlyResponse(x, set)
if (r !== undefined) return r
})
}) as any
case 'Error':
return errorToResponse(response as Error, set)
@@ -381,10 +374,10 @@ export const mapEarlyResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapEarlyResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -458,7 +451,7 @@ export const mapCompactResponse = (
return errorToResponse(response as Error)
case 'Promise':
return (response as any as Promise<unknown>).then((x) =>
return (response as Promise<unknown>).then((x) =>
mapCompactResponse(x, request)
) as any
@@ -501,12 +494,12 @@ export const mapCompactResponse = (
)
return handleStream(response as any, undefined, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapCompactResponse(x, request)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapCompactResponse(x, request)
) as any
// @ts-expect-error
// @ts-expect-errors
if (typeof response?.toResponse === 'function')
return mapCompactResponse((response as any).toResponse())
@@ -532,15 +525,14 @@ export const errorToResponse = (error: Error, set?: Context['set']) => {
// @ts-expect-error
const raw = error.toResponse()
const targetSet =
set ?? ({ headers: {}, status: 200, redirect: '' } as Context['set'])
set ??
({ headers: {}, status: 200, redirect: '' } as Context['set'])
const apply = (resolved: unknown) => {
if (resolved instanceof Response) targetSet.status = resolved.status
return mapResponse(resolved, targetSet)
}
return typeof raw?.then === 'function'
? raw.then(apply)
: apply(raw)
return typeof raw?.then === 'function' ? raw.then(apply) : apply(raw)
}
return new Response(
+28 -28
View File
@@ -13,7 +13,7 @@ import { Cookie } from '../../cookies'
import { ElysiaCustomStatusResponse } from '../../error'
import type { Context } from '../../context'
import type { AnyLocalHook } from '../../types'
import type { AnyLocalHook, MaybePromise } from '../../types'
const handleElysiaFile = (
file: ElysiaFile,
@@ -149,10 +149,10 @@ export const mapResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapResponse(x, set)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -234,10 +234,9 @@ export const mapEarlyResponse = (
return handleResponse(response as Response, set, request)
case 'Promise':
// @ts-ignore
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
)
) as any
case 'Error':
return errorToResponse(response as Error, set)
@@ -290,10 +289,10 @@ export const mapEarlyResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapEarlyResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -357,11 +356,10 @@ export const mapEarlyResponse = (
return response as Response
case 'Promise':
// @ts-ignore
return (response as Promise<unknown>).then((x) => {
const r = mapEarlyResponse(x, set)
if (r !== undefined) return r
})
}) as any
case 'Error':
return errorToResponse(response as Error, set)
@@ -410,10 +408,10 @@ export const mapEarlyResponse = (
)
return handleStream(response as any, set, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapEarlyResponse(x, set)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapEarlyResponse(x, set)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -534,10 +532,10 @@ export const mapCompactResponse = (
)
return handleStream(response as any, undefined, request) as any
// @ts-expect-error
if (typeof response?.then === 'function')
// @ts-expect-error
return response.then((x) => mapCompactResponse(x, request)) as any
if (typeof (response as Promise<unknown>)?.then === 'function')
return (response as Promise<unknown>).then((x) =>
mapCompactResponse(x, request)
) as any
// @ts-expect-error
if (typeof response?.toResponse === 'function')
@@ -559,21 +557,23 @@ export const mapCompactResponse = (
}
}
export const errorToResponse = (error: Error, set?: Context['set']) => {
// @ts-expect-error
export const errorToResponse = (
error: Error & { toResponse?(): MaybePromise<Response> },
set?: Context['set']
) => {
if (typeof error?.toResponse === 'function') {
// @ts-expect-error
const raw = error.toResponse()
const targetSet =
set ?? ({ headers: {}, status: 200, redirect: '' } as Context['set'])
set ??
({ headers: {}, status: 200, redirect: '' } as Context['set'])
const apply = (resolved: unknown) => {
if (resolved instanceof Response) targetSet.status = resolved.status
return mapResponse(resolved, targetSet)
}
return typeof raw?.then === 'function'
? raw.then(apply)
: apply(raw)
// @ts-ignore
return typeof raw?.then === 'function' ? raw.then(apply) : apply(raw)
}
return new Response(