File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ if (process.env.CI === "true") {
7777 command : `node entry-node-fast-fetch.js` ,
7878 skipCryptoTest : nodeVersionMajor < 16 ,
7979 } ,
80+ {
81+ name : "Node HTTP/2 with native fetch" ,
82+ platform : "node" ,
83+ command : "node --experimental-fetch entry-node-http2.js" ,
84+ } ,
8085 {
8186 name : "Deno" ,
8287 platform : "deno" ,
Original file line number Diff line number Diff line change 1+ // @ts -check
2+ import * as http2 from "node:http2" ;
3+ import { createMiddleware } from "@hattip/adapter-node/http2" ;
4+ import handler from "./index.js" ;
5+ import { walk } from "@hattip/walk" ;
6+ import { createStaticMiddleware } from "@hattip/static/node" ;
7+
8+ const root = new URL ( "./public" , import . meta. url ) ;
9+ const files = walk ( root ) ;
10+
11+ /**
12+ * @type {(request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => boolean }
13+ */
14+ const staticMiddleware = createStaticMiddleware ( root , files , { gzip : true } ) ;
15+ const middleware = createMiddleware ( handler ) ;
16+
17+ http2
18+ . createServer ( ( req , res ) => {
19+ return staticMiddleware ( req , res ) || middleware ( req , res ) ;
20+ } )
21+ . listen ( 3000 , "127.0.0.1" , ( ) => {
22+ console . log ( "Server listening on http://127.0.0.1:3000" ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments