File tree Expand file tree Collapse file tree 2 files changed +15
-23
lines changed Expand file tree Collapse file tree 2 files changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,13 @@ import { cors } from '@elysiajs/cors'
3
3
import { swagger } from '@elysiajs/swagger'
4
4
import { node } from '../src'
5
5
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
+ )
17
14
. get ( '/' , ( ) => 'ok' )
18
- . ws ( '/ws' , {
19
- message ( ws , message ) {
20
- ws . send ( message )
21
- }
22
- } )
23
15
. listen ( 3000 )
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ export const node = () => {
80
80
} ,
81
81
composeHandler : {
82
82
declare ( inference ) {
83
- if ( inference . request || inference . request )
83
+ if ( inference . request || inference . cookie )
84
84
return (
85
85
`if(!('request' in c)){` +
86
86
`let _request\n` +
@@ -215,12 +215,12 @@ export const node = () => {
215
215
fnLiteral += `let _request\n` + `const c={`
216
216
217
217
// @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
+ `},`
224
224
225
225
fnLiteral +=
226
226
`store,` +
You can’t perform that action at this time.
0 commit comments