Skip to content

Commit fd9c97e

Browse files
fix: http util should return the result as well (#36)
* fix: http util should return the result as well * fix: type * fix: biome * fix: biome * chore: moving back to void
1 parent e342e00 commit fd9c97e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/node/iii/src/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { StreamChannelRef } from './iii-types'
2-
import type { HttpRequest, HttpResponse, InternalHttpRequest } from './types'
2+
import type { ApiResponse, HttpRequest, HttpResponse, InternalHttpRequest } from './types'
33

44
/**
55
* Safely stringify a value, handling circular references, BigInt, and other edge cases.
@@ -30,7 +30,10 @@ export function safeStringify(value: unknown): string {
3030
}
3131
}
3232

33-
export const http = (callback: (req: HttpRequest, res: HttpResponse) => Promise<void>) => {
33+
export const http = (
34+
// biome-ignore lint/suspicious/noConfusingVoidType: void is necessary here
35+
callback: (req: HttpRequest, res: HttpResponse) => Promise<void | ApiResponse>,
36+
) => {
3437
return async (req: InternalHttpRequest) => {
3538
const { response, ...request } = req
3639

@@ -43,7 +46,7 @@ export const http = (callback: (req: HttpRequest, res: HttpResponse) => Promise<
4346
close: () => response.close(),
4447
}
4548

46-
await callback(request, httpResponse)
49+
return callback(request, httpResponse)
4750
}
4851
}
4952

0 commit comments

Comments
 (0)