Files
SnowLuma/.pnpm-store/v11/files/ef/689555a3585778e08be14f03f9256912625d0777adb60fe1f5105a1f9007474d093518008b692f182fc39ddc295ea2df3a1e941e15325de50d22421b941e30
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

23 lines
777 B
Plaintext

import { getBunServer } from "./server.js";
//#region src/adapter/bun/conninfo.ts
/**
* Get ConnInfo with Bun
* @param c Context
* @returns ConnInfo
* @deprecated `hono/bun` will be removed in v5. Install `@hono/bun` and import from there instead.
*/
const getConnInfo = (c) => {
const server = getBunServer(c);
if (!server) throw new TypeError("env has to include the 2nd argument of fetch.");
if (typeof server.requestIP !== "function") throw new TypeError("server.requestIP is not a function.");
const info = server.requestIP(c.req.raw);
if (!info) return { remote: {} };
return { remote: {
address: info.address,
addressType: info.family === "IPv6" || info.family === "IPv4" ? info.family : void 0,
port: info.port
} };
};
//#endregion
export { getConnInfo };