Files
SnowLuma/.pnpm-store/v11/files/17/f4554d707d2a04e71487e3614b4d2305d073656258e3ff4bd8e187d66f59f21b1175d973ee0dcbf501b7fe7f59496e5a92280ef3857c74367bae6a2b4df467
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

37 lines
1.0 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_middleware_serve_static_index = require("../../middleware/serve-static/index.js");
let node_path = require("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 require_middleware_serve_static_index.serveStatic({
...options,
getContent,
join: node_path.join,
isDir
})(c, next);
};
};
//#endregion
exports.serveStatic = serveStatic;