@bunny.net/edgescript-sdk

中文文档
0.13.0发布于 2026/09/23MITTypeScriptESM + CJS近 30 天下载 3万

原始使用文档
文档目录5 节
  1. 🥕 Usage
  2. Hello World Example
  3. Parameter Explanation
  4. 🚀 Deploying to Bunny Edge
  5. 🚨 Error Handling and Logging

@bunny.net/edge-script-sdk


Bunny Edge Scripting SDK

This repository contains @bunny.net/edgescript-sdk, a library designed to simplify the development and testing of applications on the Bunny Edge Scripting platform. With this SDK, you can build, debug, and run scripts locally, then deploy them seamlessly to Bunny’s global edge network for production.

Under the hood, Bunny Edge Scripting is built on Deno, and includes a custom runtime that supports running scripts interchangeably in both local and Bunny edge environments. This SDK emulates that environment locally, letting you develop and test your scripts with confidence before deploying them.

Note: While the Bunny runtime closely matches Deno and Node behaviors, some APIs may differ or be restricted due to the unique requirements of running applications in a serverless CDN-based environment.

🥕 Usage

With @bunny.net/edgescript-sdk, you can write scripts that run smoothly on Deno, Node, and within the bunny.net network. Below is a quick example to help you get started with setting up a local server. For additional examples and use cases, refer to the examples folder.

Hello World Example

import * as BunnySDK from "@bunny.net/edgescript-sdk";

function sleep(ms: number): Promise<void> {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

console.log("Starting server...");

BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (req) => {
  console.log(`[INFO]: ${req.method} - ${req.url}`);
  await sleep(1000); // Simulate some processing delay
  return new Response("Hello, Bunny Edge!");
});

This example sets up a local HTTP server using the Bunny Edge Scripting SDK. You can access the server at 127.0.0.1:8080 and observe the real-time request logs. This setup mimics the way Bunny's edge network handles requests, providing a consistent development experience.

Parameter Explanation

  • port: The port on which the server will listen for incoming HTTP requests. In this example, 8080 is specified, so you can access the server at http://127.0.0.1:8080.

  • hostname: The hostname or IP address for the server. Here, '127.0.0.1' restricts the server to listen only on the local machine (localhost). To make it accessible over the network, you could set it to '0.0.0.0', allowing other devices to connect to the server.

🚀 Deploying to Bunny Edge

After local development and testing, deploying to Bunny Edge Scripting is straightforward. Simply push your code to your Bunny Edge Scripting project’s GitHub repository, and it will be automatically deployed across Bunny’s global CDN.

Once deployed, Bunny’s serve function processes incoming requests through a connected Pull Zone, allowing your application to deliver data from the edge with maximum speed and minimal latency.

🚨 Error Handling and Logging

Bunny Edge Scripting includes built-in logging to support error tracking and observability. Use console.log, console.warn, and console.error statements within your code to monitor application flow, debug issues, and gather insights both locally and in deployment.

版本与发布记录

@bunny.net/edgescript-sdk 共发布 21 个版本,首次发布于 2024/08/14;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.13.0latest2026/09/231 个月前
0.13.0-rc.0rc2026/05/265 个月前
0.12.12026/02/069 个月前
0.12.02025/03/201.6 年前
0.11.52025/03/051.7 年前
0.11.42025/03/051.7 年前

关于 @bunny.net/edgescript-sdk 的常见问题

如何安装 @bunny.net/edgescript-sdk?

在项目目录运行 npm install @bunny.net/edgescript-sdk,或使用 pnpm add / yarn add / bun add。

@bunny.net/edgescript-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bunny.net/edgescript-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bunny.net/edgescript-sdk 可以商用吗?

@bunny.net/edgescript-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bunny.net/edgescript-sdk 的下载量有多少?

根据 npm 官方下载统计,@bunny.net/edgescript-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 30,440 次,日均约 1,015 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bunny.net/edgescript-sdk 还在维护吗?

最新版本 0.13.0 发布于 2026/09/23(1 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 3 个;首次发布于 2024/08/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。