Files
SnowLuma/.pnpm-store/v11/files/7a/ac1ad46f17d8965e158f7de7200667f1daa21293f118c5025167883985156c94a31bcfaf2c7dc5ab5d4b5e4cb0372730f5e0927a7977c931bd28c4cf84abe7
TanTan 2a69b23b47
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
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

68 lines
2.1 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_http_exception = require("../../http-exception.js");
const require_context = require("../../context.js");
//#region src/adapter/cloudflare-pages/handler.ts
/**
* @deprecated `hono/cloudflare-pages` will be removed in v5. Cloudflare recommends Workers with static assets; use `hono` on Workers instead.
*/
const handle = (app) => (eventContext) => {
return app.fetch(eventContext.request, {
...eventContext.env,
eventContext
}, {
waitUntil: eventContext.waitUntil,
passThroughOnException: eventContext.passThroughOnException,
props: {}
});
};
/**
* @deprecated `hono/cloudflare-pages` will be removed in v5. Cloudflare recommends Workers with static assets; use `hono` on Workers instead.
*/
function handleMiddleware(middleware) {
return async (executionCtx) => {
const context = new require_context.Context(executionCtx.request, {
env: {
...executionCtx.env,
eventContext: executionCtx
},
executionCtx
});
let response = void 0;
try {
response = await middleware(context, async () => {
try {
context.res = await executionCtx.next();
} catch (error) {
if (error instanceof Error) context.error = error;
else throw error;
}
});
} catch (error) {
if (error instanceof Error) context.error = error;
else throw error;
}
if (response) return response;
if (context.error instanceof require_http_exception.HTTPException) return context.error.getResponse();
if (context.error) throw context.error;
return context.res;
};
}
/**
*
* @description `serveStatic()` is for advanced mode:
* https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-function
*
* @deprecated `hono/cloudflare-pages` will be removed in v5. Cloudflare recommends Workers with static assets; use `hono` on Workers instead.
*/
const serveStatic = () => {
return async (c) => {
const res = await c.env.ASSETS.fetch(c.req.raw);
if (res.status === 404) return c.notFound();
return res;
};
};
//#endregion
exports.handle = handle;
exports.handleMiddleware = handleMiddleware;
exports.serveStatic = serveStatic;