Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
31 lines
788 B
Plaintext
31 lines
788 B
Plaintext
import { serveStatic as serveStatic$1 } from "../../middleware/serve-static/index.js";
|
|
import { stat } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
//#region src/adapter/bun/serve-static.ts
|
|
/**
|
|
* @deprecated `hono/bun` will be removed in v5. Install `@hono/bun` and import from there instead.
|
|
*/
|
|
const serveStatic = (options = {}) => {
|
|
return async function serveStatic(c, next) {
|
|
const getContent = async (path) => {
|
|
const file = Bun.file(path);
|
|
return await file.exists() ? file : null;
|
|
};
|
|
const isDir = async (path) => {
|
|
let isDir;
|
|
try {
|
|
isDir = (await stat(path)).isDirectory();
|
|
} catch {}
|
|
return isDir;
|
|
};
|
|
return serveStatic$1({
|
|
...options,
|
|
getContent,
|
|
join,
|
|
isDir
|
|
})(c, next);
|
|
};
|
|
};
|
|
//#endregion
|
|
export { serveStatic };
|