Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DejanPelzel authored Nov 7, 2024
1 parent d388064 commit 7aa3102
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

# bunny.net - Bunny Edge Scripting SDK

Welcome to the Bunny Edge Scripting SDK repository! This library, `@bunny.net/edgescript-sdk`, provides a seamless way to develop and test applications for the Bunny Edge Scripting platform. With this SDK, you can build, debug, and run scripts locally and later deploy them effortlessly to Bunny’s global edge network into a production environment.
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 top of Deno. To provide a seamless integration, Edge Scripting provides a custom runtime that was designed to run scripts interchangibly between a local environment, and across the bunny.net edge network. This SDK replicates a similar environment locally, allowing you to develop and debug your scripts before deploying them.
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: The Bunny Runtime attempts to closely match the behavior of Deno and Node runtimes, but certain APIs
> may be different or unavailable due to the unique platform requirements of running applications in a serverless CDN environment.
> **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 create scripts that run seamlessly on Deno,
Node, and within the bunny.net network.
With `@bunny.net/edgescript-sdk`, you can write scripts that run smoothly on Deno, Node, and within the bunny.net network.

```typescript
import * as BunnySDK from "@bunny.net/edgescript-sdk";
Expand All @@ -29,19 +27,19 @@ 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(1);
return new Response("blbl");
await sleep(1000); // Simulate some processing delay
return new Response("Hello, Bunny Edge!");
});
```

This code sets up a local HTTP server using the Bunny Edge Scripting SDK. You can access the server at 127.0.0.1:8080 and see it log incoming requests in real-time. This setup closely resembles how your script will handle requests on Bunny's edge network.
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.

## Deploying to Bunny Edge
Once you’ve developed and tested your code locally, deploying to Bunny Edge Scripting is simple. Push your code to your Bunny Edge Scripting project’s GitHub repository, and it will automatically be deployed across Bunny’s global CDN.
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 via a connected Pull Zone, enabling your application to deliver data at the edge with optimal speed and minimal latency.
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
To assist with debugging and enhance observability, Bunny Edge Scripting includes built-in logging support. Use console.log, console.warn, and console.error statements within your code to track application flow, errors, and other details during local development and edge deployment.
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.

For more examples, refer to the [examples folder](./example/).
For additional examples and use cases, refer to the [examples folder](./example/).

0 comments on commit 7aa3102

Please sign in to comment.