File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Backend server
2
+ const backendServer = Bun . serve ( {
3
+ port : 3001 ,
4
+
5
+ async fetch ( req : Request ) : Promise < Response > {
6
+ const url = new URL ( req . url )
7
+
8
+ if ( url . pathname === "/users" ) {
9
+ return new Response ( JSON . stringify ( [ ] ) , {
10
+ headers : { "content-type" : "application/json" } ,
11
+ } )
12
+ }
13
+
14
+ return new Response ( "Not Found" , { status : 404 } )
15
+ } ,
16
+ } )
Original file line number Diff line number Diff line change
1
+ import createFetchGate from "../index"
2
+ import { createSilentLogger } from "../src/logger"
3
+
4
+ const { proxy } = createFetchGate ( {
5
+ base : "http://127.0.0.1:3001" ,
6
+ logger : createSilentLogger ( ) ,
7
+ } )
8
+
9
+ // Gateway server
10
+ const gatewayServer = Bun . serve ( {
11
+ port : 3000 ,
12
+
13
+ async fetch ( req : Request ) : Promise < Response > {
14
+ const url = new URL ( req . url )
15
+
16
+ if ( url . pathname === "/api/users" ) {
17
+ return proxy ( req , "/users" )
18
+ }
19
+
20
+ return new Response ( "Not Found" , { status : 404 } )
21
+ } ,
22
+ } )
You can’t perform that action at this time.
0 commit comments