Skip to content

Commit e2f7606

Browse files
committed
optimize serveFromDir
1 parent a7cae69 commit e2f7606

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FileSystemRouter } from "bun";
22
import { NJSON } from "next-json";
3+
import { statSync } from "node:fs";
34
import { join, relative } from "node:path";
4-
import { Suspense } from "react";
55
import { renderToReadableStream } from "react-dom/server";
66

77
export class StaticRouters {
@@ -117,9 +117,9 @@ export async function serveFromDir(config: {
117117
for (const suffix of suffixes) {
118118
try {
119119
const pathWithSuffix = join(basePath, suffix);
120-
const file = Bun.file(pathWithSuffix);
121-
if (await file.exists()) {
122-
return new Response(Bun.file(pathWithSuffix));
120+
const stat = statSync(pathWithSuffix);
121+
if (stat?.isFile()) {
122+
return Bun.file(pathWithSuffix);
123123
}
124124
} catch (err) {}
125125
}

0 commit comments

Comments
 (0)