@@ -51,10 +51,9 @@ export async function serverResponse(req: Request, body: string) {
51
51
// This automatically allows for route definitions, like
52
52
// '/about' and '/about/' to be treated as the same
53
53
const trimmedUrl = req . url . endsWith ( '/' ) && req . url . length > 1 ? req . url . slice ( 0 , - 1 ) : req . url
54
-
55
54
const url = new URL ( trimmedUrl )
56
-
57
55
const routesList : Route [ ] = await route . getRoutes ( )
56
+
58
57
log . info ( `Routes List: ${ JSON . stringify ( routesList ) } ` , { styled : false } )
59
58
log . info ( `URL: ${ JSON . stringify ( url ) } ` , { styled : false } )
60
59
@@ -145,7 +144,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
145
144
146
145
const { status, ...payloadWithoutStatus } = middlewarePayload
147
146
148
- return await new Response ( JSON . stringify ( payloadWithoutStatus ) , {
147
+ return new Response ( JSON . stringify ( payloadWithoutStatus ) , {
149
148
headers : {
150
149
'Content-Type' : 'json' ,
151
150
'Access-Control-Allow-Origin' : '*' ,
@@ -161,7 +160,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
161
160
const callback = String ( foundCallback )
162
161
const response = Response . redirect ( callback , statusCode )
163
162
164
- return await noCache ( response )
163
+ return noCache ( response )
165
164
}
166
165
167
166
if ( foundRoute ?. method !== req . method ) {
@@ -179,15 +178,15 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
179
178
try {
180
179
const fileContent = Bun . file ( foundCallback )
181
180
182
- return await new Response ( fileContent , {
181
+ return new Response ( fileContent , {
183
182
headers : {
184
183
'Content-Type' : 'text/html' ,
185
184
'Access-Control-Allow-Origin' : '*' ,
186
185
'Access-Control-Allow-Headers' : '*' ,
187
186
} ,
188
187
} )
189
188
} catch ( error ) {
190
- return await new Response ( 'Error reading the HTML file' , {
189
+ return new Response ( 'Error reading the HTML file' , {
191
190
status : 500 ,
192
191
headers : {
193
192
'Access-Control-Allow-Origin' : '*' ,
@@ -198,7 +197,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
198
197
}
199
198
200
199
if ( isString ( foundCallback ) )
201
- return await new Response ( foundCallback , {
200
+ return new Response ( foundCallback , {
202
201
headers : {
203
202
'Content-Type' : 'json' ,
204
203
'Access-Control-Allow-Origin' : '*' ,
@@ -210,7 +209,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
210
209
if ( isFunction ( foundCallback ) ) {
211
210
const result = foundCallback ( )
212
211
213
- return await new Response ( JSON . stringify ( result ) , {
212
+ return new Response ( JSON . stringify ( result ) , {
214
213
status : 200 ,
215
214
headers : {
216
215
'Access-Control-Allow-Origin' : '*' ,
@@ -223,7 +222,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
223
222
if ( foundCallback . status === 401 ) {
224
223
const { status, ...rest } = foundCallback
225
224
226
- return await new Response ( JSON . stringify ( rest ) , {
225
+ return new Response ( JSON . stringify ( rest ) , {
227
226
headers : {
228
227
'Content-Type' : 'json' ,
229
228
'Access-Control-Allow-Origin' : '*' ,
@@ -236,7 +235,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
236
235
if ( foundCallback . status === 403 ) {
237
236
const { status, ...rest } = foundCallback
238
237
239
- return await new Response ( JSON . stringify ( rest ) , {
238
+ return new Response ( JSON . stringify ( rest ) , {
240
239
headers : {
241
240
'Content-Type' : 'json' ,
242
241
'Access-Control-Allow-Origin' : '*' ,
@@ -249,7 +248,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
249
248
if ( foundCallback . status === 422 ) {
250
249
const { status, ...rest } = foundCallback
251
250
252
- return await new Response ( JSON . stringify ( rest ) , {
251
+ return new Response ( JSON . stringify ( rest ) , {
253
252
headers : {
254
253
'Content-Type' : 'json' ,
255
254
'Access-Control-Allow-Origin' : '*' ,
@@ -262,15 +261,15 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
262
261
if ( foundCallback . status === 500 ) {
263
262
const { status, ...rest } = foundCallback
264
263
265
- return await new Response ( JSON . stringify ( rest ) , {
264
+ return new Response ( JSON . stringify ( rest ) , {
266
265
headers : { 'Content-Type' : 'json' , 'Access-Control-Allow-Origin' : '*' , 'Access-Control-Allow-Headers' : '*' } ,
267
266
status : 500 ,
268
267
} )
269
268
}
270
269
}
271
270
272
271
if ( isObject ( foundCallback ) ) {
273
- return await new Response ( JSON . stringify ( foundCallback ) , {
272
+ return new Response ( JSON . stringify ( foundCallback ) , {
274
273
headers : {
275
274
'Content-Type' : 'json' ,
276
275
'Access-Control-Allow-Origin' : '*' ,
@@ -281,7 +280,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
281
280
}
282
281
283
282
// If no known type matched, return a generic error.
284
- return await new Response ( 'Unknown callback type.' , {
283
+ return new Response ( 'Unknown callback type.' , {
285
284
headers : {
286
285
'Content-Type' : 'json' ,
287
286
'Access-Control-Allow-Origin' : '*' ,
0 commit comments