diff --git a/.changeset/long-hats-run.md b/.changeset/long-hats-run.md new file mode 100644 index 0000000..f454b0a --- /dev/null +++ b/.changeset/long-hats-run.md @@ -0,0 +1,6 @@ +--- +"example/deno-simple-http-page": patch +"example/simple-http-page": patch +--- + +Added working examples with Node & Deno diff --git a/example/deno-simple-http-page/package.json b/example/deno-simple-http-page/package.json index ce39ff3..dc137fe 100644 --- a/example/deno-simple-http-page/package.json +++ b/example/deno-simple-http-page/package.json @@ -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", @@ -10,7 +22,7 @@ "release": "echo \"No release\"" }, "dependencies": { - "@bunny.net/edgescript-sdk": "^0.5.10" + "@bunny.net/edgescript-sdk": "^0.5.12" }, "devDependencies": {} } diff --git a/example/deno-simple-http-page/src/main.ts b/example/deno-simple-http-page/src/main.ts index ccf889f..dcde170 100644 --- a/example/deno-simple-http-page/src/main.ts +++ b/example/deno-simple-http-page/src/main.ts @@ -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); diff --git a/example/simple-http-page/package.json b/example/simple-http-page/package.json index 3cb90a4..08bfc08 100644 --- a/example/simple-http-page/package.json +++ b/example/simple-http-page/package.json @@ -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": { diff --git a/example/simple-http-page/src/main.ts b/example/simple-http-page/src/main.ts index 50b7e8e..27d9ed9 100644 --- a/example/simple-http-page/src/main.ts +++ b/example/simple-http-page/src/main.ts @@ -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); - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17717ef..4080bd3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: example/deno-simple-http-page: dependencies: '@bunny.net/edgescript-sdk': - specifier: ^0.5.10 - version: 0.5.10 + specifier: ^0.5.12 + version: link:../../libs/bunny-sdk example/simple-http-page: dependencies: @@ -452,13 +452,6 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@bunny.net/edgescript-sdk@0.5.10: - resolution: {integrity: sha512-1rMoph3H1PmRHY3WNcYLjyT2G+STeW/FA2AnaoXmsgurt49p1V99Je6CkoDPYuCDD4N7XtWpX4NzOg45vQuLGA==} - dependencies: - '@hono/node-server': 1.12.0 - hono: 4.5.5 - dev: false - /@changesets/apply-release-plan@7.0.4: resolution: {integrity: sha512-HLFwhKWayKinWAul0Vj+76jVx1Pc2v55MGPVjZ924Y/ROeSsBMFutv9heHmCUj48lJyRfOTJG5+ar+29FUky/A==} dependencies: