Skip to content

Commit

Permalink
feat: working examples
Browse files Browse the repository at this point in the history
  • Loading branch information
antho-bunny committed Aug 14, 2024
1 parent 7c223b4 commit d36ca8e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .changeset/long-hats-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"example/deno-simple-http-page": patch
"example/simple-http-page": patch
---

Added working examples with Node & Deno
16 changes: 14 additions & 2 deletions example/deno-simple-http-page/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"name": "example/simple-http-page",
"name": "example/deno-simple-http-page",
"version": "0.2.14",
"main": "src/index.ts",
"type": "module",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/BunnyWay/edge-script-sdk.git"
},
"keywords": [
"github",
"bunny"
],
"author": "Bunny Devs",
"license": "MIT",
"scripts": {
"lint": "deno lint",
"test": "deno test",
Expand All @@ -10,7 +22,7 @@
"release": "echo \"No release\""
},
"dependencies": {
"@bunny.net/edgescript-sdk": "^0.5.10"
"@bunny.net/edgescript-sdk": "^0.5.12"
},
"devDependencies": {}
}
9 changes: 2 additions & 7 deletions example/deno-simple-http-page/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import * as BunnySDK from "npm:@bunny.net/edgescript-sdk";

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
import * as BunnySDK from "@bunny.net/edgescript-sdk";

console.log("Starting server...");
BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (req) => {
console.log("blbl");
console.log(req.url);
return new Response("blbl");
});
console.log("net");
await sleep(100);
4 changes: 2 additions & 2 deletions example/simple-http-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"scripts": {
"lint": "eslint src",
"test": "jest --silent --coverage",
"build": "echo \"No buil\"",
"build-full": "ncc build src/main.ts -o dist/",
"dev": "pnpm run build && node dist/index.js",
"build": "ncc build src/main.ts -o dist/",
"release": "echo \"No release\""
},
"repository": {
Expand Down
12 changes: 2 additions & 10 deletions example/simple-http-page/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import * as BunnySDK from "@bunny.net/edgescript-sdk";

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

BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (req) => {
console.log("blbl");
console.log(req.url);
console.log("Starting server...");
BunnySDK.net.http.serve({ port: 8080, hostname: '127.0.0.1' }, async (_) => {
return new Response("blbl");
});
console.log("net");
await sleep(10000);

11 changes: 2 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d36ca8e

Please sign in to comment.