Remove esm.sh externals
This commit is contained in:
+11
-8
@@ -11,14 +11,7 @@ export default async function ({ req }) {
|
||||
if (!file_path.startsWith(PUBLIC_DIR + path.sep)) {
|
||||
return new Response("Forbidden", { status: 403 });
|
||||
}
|
||||
if (!existsSync(file_path)) {
|
||||
return new Response(`Public File Doesn't Exist`, {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
const file = Bun.file(file_path);
|
||||
let res_opts = {};
|
||||
return new Response(file, res_opts);
|
||||
return readFileResponse({ file_path });
|
||||
}
|
||||
catch (error) {
|
||||
return new Response(`Public File Not Found`, {
|
||||
@@ -26,3 +19,13 @@ export default async function ({ req }) {
|
||||
});
|
||||
}
|
||||
}
|
||||
export function readFileResponse({ file_path }) {
|
||||
if (!existsSync(file_path)) {
|
||||
return new Response(`Public File Doesn't Exist`, {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
const file = Bun.file(file_path);
|
||||
// let res_opts: ResponseInit = {};
|
||||
return new Response(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user