Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.4.8
Change:
- make `file-type` optional to reduce bundle size
- [#1432](https://github.com/elysiajs/elysia/pull/1432) missing context (set) in mapResponse for ElysiaFile
- [#1435](https://github.com/elysiajs/elysia/pull/1435) missing cookies in SSE

# 1.4.7 - 22 Sep 2025
Feature:
- experimental `adapter/cloudflare-worker`
Expand Down
8 changes: 4 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 3 additions & 24 deletions example/a.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
import { Elysia, t } from '../src'
import { sucrose } from '../src/sucrose'
import { req } from '../test/utils'

const app = new Elysia()
.wrap((fn, request) => {
const _request = request.clone()

return () => {
try {
return fn(request.clone())
} catch {
console.log('ER')
}
}
})
.onError(({ error }) => {
if (error) throw error
})
.get('/', () => {
throw new Error('A')

return 'Hello World!'
})
.get('/:id', ({ params: { id } }) => 'hello')
.listen(3000)

// console.log(app.fetch.toString())

app.handle(req('/'))
.then((x) => x.text())
.then(console.log)
// app.handle(req('/1'))
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@
"openapi-types": ">= 12.0.0",
"typescript": ">= 5.0.0"
},
"optionalDependencies": {
"@sinclair/typebox": ">= 0.34.0 < 1",
"openapi-types": ">= 12.0.0"
"peerDependenciesMeta": {
"file-type": {
"optional": true
},
"typescript": {
"optional": true
}
}
}
18 changes: 8 additions & 10 deletions src/adapter/bun/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {
createResponseHandler,
createStreamHandler,
handleFile,
handleSet,
responseToSetHeaders,
streamResponse
handleSet
} from '../utils'

import { ElysiaFile } from '../../universal/file'
Expand Down Expand Up @@ -41,14 +39,14 @@ export const mapResponse = (
case 'ElysiaFile':
return handleFile(
(response as ElysiaFile).value as File,
set as any
set
)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as Blob, set as any)
return handleFile(response as Blob, set)

case 'ElysiaCustomStatusResponse':
set.status = (response as ElysiaCustomStatusResponse<200>).code
Expand Down Expand Up @@ -182,10 +180,10 @@ export const mapEarlyResponse = (
return new Response(JSON.stringify(response), set as any)

case 'ElysiaFile':
return handleFile((response as ElysiaFile).value as File)
return handleFile((response as ElysiaFile).value as File, set)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as File | Blob, set)
Expand Down Expand Up @@ -300,10 +298,10 @@ export const mapEarlyResponse = (
return new Response(JSON.stringify(response), set as any)

case 'ElysiaFile':
return handleFile((response as ElysiaFile).value as File)
return handleFile((response as ElysiaFile).value as File, set)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as File | Blob, set)
Expand Down
8 changes: 4 additions & 4 deletions src/adapter/web-standard/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ export const mapResponse = (
return handleElysiaFile(response as ElysiaFile, set)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as Blob, set as any)
return handleFile(response as Blob, set)

case 'ElysiaCustomStatusResponse':
set.status = (response as ElysiaCustomStatusResponse<200>).code
Expand Down Expand Up @@ -211,7 +211,7 @@ export const mapEarlyResponse = (
return handleElysiaFile(response as ElysiaFile, set)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as File | Blob, set)
Expand Down Expand Up @@ -330,7 +330,7 @@ export const mapEarlyResponse = (
return handleElysiaFile(response as ElysiaFile, set)

case 'File':
return handleFile(response as File, set as any)
return handleFile(response as File, set)

case 'Blob':
return handleFile(response as File | Blob, set)
Expand Down
5 changes: 1 addition & 4 deletions src/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,8 @@ export const composeHandler = ({
const hasTrace = !!hooks.trace?.length
let fnLiteral = ''

inference = sucrose(hooks, inference)
inference = sucrose(
{
handler: handler as any
},
Object.assign({ handler: handler as any }, hooks),
inference
)

Expand Down
2 changes: 2 additions & 0 deletions src/sucrose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,9 @@ export const sucrose = (
if (typeof event !== 'function') continue

const content = event.toString()
console.log(content)
const key = checksum(content)
console.log(key)
const cachedInference = caches[key]
if (cachedInference) {
inference = mergeInference(inference, cachedInference)
Expand Down
Loading