Files
SnowLuma/.pnpm-store/v11/files/2d/540bef50e41c1188fa5e0a23931f9e400a2c4309968c390866ed87d0030548c870c4a54c6cb79cb2140e41760403ff84d4734cd5231a0c7fca77085ce331c6
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

36 lines
889 B
Plaintext

import { serveStatic as serveStatic$1 } from "../../middleware/serve-static/index.js";
import { join } from "node:path";
//#region src/adapter/deno/serve-static.ts
const { open, lstatSync, errors } = Deno;
/**
* @deprecated `hono/deno` will be removed in v5. Install `@hono/deno` and import from there instead.
*/
const serveStatic = (options = {}) => {
return async function serveStatic(c, next) {
const getContent = async (path) => {
try {
if (isDir(path)) return null;
return (await open(path)).readable;
} catch (e) {
if (!(e instanceof errors.NotFound)) console.warn(`${e}`);
return null;
}
};
const isDir = (path) => {
let isDir;
try {
isDir = lstatSync(path).isDirectory;
} catch {}
return isDir;
};
return serveStatic$1({
...options,
getContent,
join,
isDir
})(c, next);
};
};
//#endregion
export { serveStatic };