Skip to content

Commit e0d1389

Browse files
committed
🔧 fix: check if body is not locked
1 parent aa46fd8 commit e0d1389

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

example/index.ts

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

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-
})
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+
)
1714
.get('/', () => 'ok')
18-
.ws('/ws', {
19-
message(ws, message) {
20-
ws.send(message)
21-
}
22-
})
2315
.listen(3000)

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const node = () => {
8080
},
8181
composeHandler: {
8282
declare(inference) {
83-
if (inference.request || inference.request)
83+
if (inference.request || inference.cookie)
8484
return (
8585
`if(!('request' in c)){` +
8686
`let _request\n` +
@@ -215,12 +215,12 @@ export const node = () => {
215215
fnLiteral += `let _request\n` + `const c={`
216216

217217
// @ts-ignore protected
218-
// if (app.inference.request || app.inference.cookie)
219-
// fnLiteral +=
220-
// `get request(){` +
221-
// `if(_request)return _request\n` +
222-
// `return _request = nodeRequestToWebstand(r)` +
223-
// `},`
218+
if (app.inference.request || app.inference.cookie)
219+
fnLiteral +=
220+
`get request(){` +
221+
`if(_request)return _request\n` +
222+
`return _request = nodeRequestToWebstand(r)` +
223+
`},`
224224

225225
fnLiteral +=
226226
`store,` +

0 commit comments

Comments
 (0)