Skip to content

Commit caf8621

Browse files
committed
🔧 fix: #34
1 parent e0d1389 commit caf8621

8 files changed

Lines changed: 66 additions & 374 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.2.6 - 21 Feb 2025
2+
Bug fix:
3+
- [#34](https://github.com/elysiajs/node/issues/34) ERR_HTTP_HEADERS_SENT when sending FormData
4+
- [#29](https://github.com/elysiajs/node/issues/29), [#30](https://github.com/elysiajs/node/pull/30) server.reload() causes Uncaught AddrInUse: Address already in use
5+
16
# 1.2.5 - 1 Feb 2025
27
Bug fix:
38
- [#23](https://github.com/elysiajs/node/issues/23) Response body object should not be disturbed or locked

bun.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/c.ts

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
1-
import { Elysia, t } from 'elysia'
2-
import { ElysiaNodeContext, node } from '../src'
1+
import { Elysia } from 'elysia'
2+
import node from '../src'
33

4-
const app = new Elysia({
4+
export const elysiaApp = new Elysia({
55
adapter: node()
66
})
7-
.onError(({ request }) => {
8-
return
9-
})
10-
.post(
11-
'/',
12-
({ body }) => {
13-
console.log({ body })
14-
15-
return 'OK'
16-
},
17-
{
18-
body: t.Object({
19-
test: t.String()
20-
})
21-
}
22-
)
23-
.listen(3000)
24-
25-
// console.log(app._handle.toString())
26-
// console.log(app.routes[0].compile().toString())
27-
// console.log(app.handleError.toString())
7+
// .onError(({ error }) => {
8+
// console.log(error)
9+
// })
10+
.patch('/', () => {
11+
const form = new FormData()
12+
form.append('name', 'Sancho')
13+
form.append('alias', 'Don Quixote')
2814

29-
const main = async () => {
30-
const res = await fetch('http://localhost:3000/', {
31-
method: 'POST',
32-
headers: {
33-
'Content-Type': 'application/json'
34-
},
35-
body: JSON.stringify({ bad: '' })
15+
return form
3616
})
3717

38-
console.log('status', res.status)
18+
export type ElysiaApp = typeof elysiaApp
3919

40-
// app.stop(true)
41-
}
20+
elysiaApp.listen(3334)
21+
console.log('Server started at http://localhost:3334')
4222

43-
main()
23+
fetch('http://localhost:3334/', { method: 'PATCH' })
24+
.then((x) => x.formData())
25+
.then(console.log)

example/index.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import { cors } from '@elysiajs/cors'
33
import { swagger } from '@elysiajs/swagger'
44
import { node } from '../src'
55

6-
const app = new Elysia({ adapter: node() })
7-
.use((app) =>
8-
app
9-
.derive({ as: 'global' }, async ({ cookie }) => {})
10-
.onAfterHandle({ as: 'global' }, async ({ response }) => {
11-
return response
12-
})
13-
)
6+
const plugin = async () => new Elysia().get('/async', () => 'ok')
7+
8+
const app = new Elysia({
9+
adapter: node()
10+
})
11+
.use(cors())
12+
.use(swagger())
13+
.get('/image', () => file('test/kyuukurarin.mp4'))
14+
.post('/', ({ body }) => body, {
15+
type: 'json'
16+
})
1417
.get('/', () => 'ok')
18+
.ws('/ws', {
19+
message(ws, message) {
20+
ws.send(message)
21+
}
22+
})
1523
.listen(3000)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@types/formidable": "^3.4.5",
3232
"@types/node": "^22.10.2",
3333
"@types/ws": "^8.5.13",
34-
"elysia": "^1.2.11",
34+
"elysia": "1.2.11",
3535
"eslint": "9.17.0",
3636
"light-my-request": "^6.4.0",
3737
"tsup": "^8.3.5",

0 commit comments

Comments
 (0)