Skip to content

Commit 430d999

Browse files
authored
Merge pull request #45 from BunnyWay/feat-add-storage-lib
Adding storage library
2 parents 833fe4b + cb91698 commit 430d999

33 files changed

Lines changed: 2026 additions & 35 deletions

.changeset/fair-eggs-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bunny.net/edgescript-sdk": patch
3+
---
4+
5+
Update README.md

.changeset/hungry-eels-compete.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bunny.net/storage-sdk": minor
3+
---
4+
5+
Adding the bunny-storage library preview

.github/actions/setup-project/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: 'Setup node, deno, pnpm and install'
55
runs:
66
using: "composite"
77
steps:
8-
- uses: pnpm/action-setup@v4.0.0
8+
- uses: pnpm/action-setup@v4.1.0
99
with:
1010
version: 9
1111

@@ -17,7 +17,7 @@ runs:
1717

1818
- uses: denoland/setup-deno@v1
1919
with:
20-
deno-version: v1.x
20+
deno-version: v2.x
2121

2222
- name: Install
2323
shell: bash

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ jobs:
2323

2424
- name: 'Test'
2525
run: pnpm run -r test
26+
env:
27+
STORAGE_ACCESS_KEY: ${{ secrets.STORAGE_ACCESS_KEY }}
28+
STORAGE_ZONE: ${{ secrets.STORAGE_ZONE }}

README.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
</a>
55
</div>
66

7-
# Bunny Edge Scripting SDK
7+
# Bunny Edge SDK
88

9-
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.
9+
This repository contains multiple libraries to work with Bunny:
1010

11-
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.
12-
13-
> **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.
11+
- [@bunny.net/edgescript-sdk](./libs/bunny-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.
12+
- [@bunny.net/storage-sdk](./libs/bunny-storage/): a library designed to help you interact with the
13+
Bunny Storage, to store & access file efficiently accross our whole network.
1414

1515
## 🥕 Usage
1616

@@ -33,18 +33,5 @@ BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (req) => {
3333
});
3434
```
3535

36-
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.
37-
38-
### Parameter Explanation
39-
40-
- **`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](http://127.0.0.1:8080).
41-
42-
- **`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.
43-
44-
## 🚀 Deploying to Bunny Edge
45-
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.
46-
47-
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.
48-
49-
## 🚨 Error Handling and Logging
50-
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.
36+
If you want more information, feel free to dive into each packages to check
37+
associated examples and documentations.

example/deno-middleware-http/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"license": "MIT",
1717
"scripts": {
1818
"lint": "deno lint",
19-
"test": "deno test --allow-none",
19+
"test": "deno test --permit-no-files",
2020
"build": "echo \"No build with Deno!\"",
2121
"dev": "deno run src/main.ts",
2222
"release": "echo \"No release\""

example/deno-simple-http-page/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"license": "MIT",
1717
"scripts": {
1818
"lint": "deno lint",
19-
"test": "deno test --allow-none",
19+
"test": "deno test --permit-no-files",
2020
"build": "echo \"No build with Deno!\"",
2121
"dev": "deno run src/main.ts",
2222
"release": "echo \"No release\""

libs/bunny-sdk/README.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
11
# @bunny.net/edge-script-sdk
22
---
33

4-
The `@bunny.net/edge-script-sdk` library gives you functions and tools you can
5-
leverage to build scripts and middleware. Those functions are optimized to be
6-
able to run in our Bunny.net Network, but you can also use them to build your
7-
scripts and run it locally with `Node` or `Deno`.
4+
<div align="center">
5+
<a href="https://bunny.net">
6+
<img src="https://github.com/BunnyWay/edge-script-sdk/blob/main/asset/bunny.png?raw=true" width="500" height="auto" alt="Bunny"/>
7+
</a>
8+
</div>
89

9-
## Usage
10+
# Bunny Edge Scripting SDK
1011

11-
With `@bunny.net/edgescript-sdk` you can write a script which will work with
12-
Deno, with Node, and within our network. Here is an example with a dynamic http
13-
import you can use with Deno.
12+
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.
1413

14+
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.
15+
16+
> **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.
17+
18+
## 🥕 Usage
19+
20+
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](./example/).
21+
22+
### Hello World Example
1523
```typescript
16-
import * as BunnySDK from "https://esm.sh/@bunny.net/edgescript-sdk@0.11";
24+
import * as BunnySDK from "@bunny.net/edgescript-sdk";
25+
26+
function sleep(ms: number): Promise<void> {
27+
return new Promise((resolve) => setTimeout(resolve, ms));
28+
}
1729

1830
console.log("Starting server...");
19-
BunnySDK.net.http.serve(async (req) => {
31+
32+
BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (req) => {
2033
console.log(`[INFO]: ${req.method} - ${req.url}`);
21-
return new Response("Hello bunny!");
34+
await sleep(1000); // Simulate some processing delay
35+
return new Response("Hello, Bunny Edge!");
2236
});
2337
```
38+
39+
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.
40+
41+
### Parameter Explanation
42+
43+
- **`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](http://127.0.0.1:8080).
44+
45+
- **`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.
46+
47+
## 🚀 Deploying to Bunny Edge
48+
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.
49+
50+
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.
51+
52+
## 🚨 Error Handling and Logging
53+
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.

libs/bunny-storage/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
/dist/
15+
/esm/
16+
/esm-bunny/
17+
18+
# production
19+
/build
20+
21+
# misc
22+
.DS_Store
23+
*.pem
24+
25+
# debug
26+
npm-debug.log*
27+
yarn-debug.log*
28+
yarn-error.log*
29+
30+
.vscode
31+
32+
# local env files
33+
.env*.local
34+
35+
# vercel
36+
.vercel
37+
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts

libs/bunny-storage/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @bunny.net/storage-sdk

0 commit comments

Comments
 (0)