fix: error handling in fs routes (#2474)
Ran into an issue where we weren't responding with the correct status code and passed response headers. This was a bit of a rabbit hole and it was caused by us wrapping to more error handling middlewares than necessary.
This commit is contained in:
+4
-6
@@ -3,8 +3,8 @@ import type { Method } from "./router.ts";
|
||||
|
||||
export interface PageResponse<T> {
|
||||
data: T;
|
||||
headers: Headers;
|
||||
status: number;
|
||||
headers?: HeadersInit;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +42,8 @@ export function page<T>(data?: T, options?: {
|
||||
}): PageResponse<T> {
|
||||
return {
|
||||
data: data ?? undefined as T,
|
||||
headers: options?.headers instanceof Headers
|
||||
? options.headers
|
||||
: new Headers(options?.headers),
|
||||
status: options?.status ?? 200,
|
||||
headers: options?.headers,
|
||||
status: options?.status,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user