mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
chore: updated cf deps, improved vite dev
This commit is contained in:
@@ -9,18 +9,28 @@ export const PLATFORMS = ["node", "bun"] as const;
|
||||
export type Platform = (typeof PLATFORMS)[number];
|
||||
|
||||
export async function serveStatic(server: Platform): Promise<MiddlewareHandler> {
|
||||
const onNotFound = (path: string) => {
|
||||
$console.debug("Couldn't resolve static file at", path);
|
||||
};
|
||||
|
||||
switch (server) {
|
||||
case "node": {
|
||||
const m = await import("@hono/node-server/serve-static");
|
||||
const root = getRelativeDistPath() + "/static";
|
||||
$console.log("Serving static files from", root);
|
||||
return m.serveStatic({
|
||||
// somehow different for node
|
||||
root: getRelativeDistPath() + "/static",
|
||||
root,
|
||||
onNotFound,
|
||||
});
|
||||
}
|
||||
case "bun": {
|
||||
const m = await import("hono/bun");
|
||||
const root = path.resolve(getRelativeDistPath(), "static");
|
||||
$console.log("Serving static files from", root);
|
||||
return m.serveStatic({
|
||||
root: path.resolve(getRelativeDistPath(), "static"),
|
||||
root,
|
||||
onNotFound,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user