File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const page = `<!DOCTYPE HTML>
13
13
</html>`
14
14
15
15
const app = new Elysia ( )
16
- . use ( html )
16
+ . use ( html ( ) )
17
17
. get ( '/' , ( ) => page )
18
18
. get ( '/html' , ( { html } ) => html ( page ) )
19
19
. listen ( 8080 )
Original file line number Diff line number Diff line change 33
33
"release" : " npm run build && npm run test && npm publish --access public"
34
34
},
35
35
"peerDependencies" : {
36
- "elysia" : " >= 0.1.0-rc.5 "
36
+ "elysia" : " >= 0.4.10 "
37
37
},
38
38
"devDependencies" : {
39
39
"@types/node" : " ^18.11.7" ,
40
- "bun-types" : " ^0.2.2 " ,
40
+ "bun-types" : " ^0.5.8 " ,
41
41
"eslint" : " ^8.26.0" ,
42
- "elysia" : " ^0.3.0-rc.1 " ,
42
+ "elysia" : " ^0.4.10 " ,
43
43
"rimraf" : " ^3.0.2" ,
44
44
"typescript" : " ^4.8.4"
45
45
}
Original file line number Diff line number Diff line change @@ -2,15 +2,24 @@ import { Elysia } from 'elysia'
2
2
3
3
export const html = ( ) => ( app : Elysia ) =>
4
4
app
5
- . decorate (
6
- 'html' ,
7
- ( value : string ) =>
8
- new Response ( value , {
5
+ . derive ( ( context ) => ( {
6
+ html ( value : string ) {
7
+
8
+ //! error: expect(received).toBe(expected)
9
+ //! Expected: "text/html"
10
+ //! Received: "text/html, text/html"
11
+
12
+ // context.set.headers['content-type'] = 'text/html';
13
+ // return new Response(value, { headers: context.set.headers });
14
+
15
+ return new Response ( value , {
9
16
headers : {
17
+ ...context . set . headers ,
10
18
'content-type' : 'text/html'
11
19
}
12
20
} )
13
- )
21
+ }
22
+ } ) )
14
23
. onAfterHandle ( ( context , response ) => {
15
24
if (
16
25
typeof response === 'string' &&
You can’t perform that action at this time.
0 commit comments