From 7701612f0af33f3fc5264e6e0e1321c89a5e8815 Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Mon, 25 May 2026 21:08:12 +0700 Subject: [PATCH 1/3] feat: align examples with guide series progression - Add upload-and-download example folder (new, was missing) - Add .env.example to all example folders - Update .gitignore to exclude .env in filesystem, routing, routing-manifest, multi-author-blog - Add npm run scripts to dynamic-content and multi-author-blog - Add website package.json and .gitignore Co-Authored-By: Claude Sonnet 4.6 --- dynamic-content/.env.example | 2 + dynamic-content/package.json | 5 +++ filesystem/.env.example | 5 +++ filesystem/.gitignore | 1 + multi-author-blog/.env.example | 2 + multi-author-blog/.gitignore | 1 + multi-author-blog/package.json | 7 ++++ routing-manifest/.env.example | 5 +++ routing-manifest/.gitignore | 3 +- routing/.env.example | 4 ++ routing/.gitignore | 3 +- simple-blog/.env.example | 2 + upload-and-download/.env.example | 2 + upload-and-download/.gitignore | 2 + upload-and-download/package.json | 14 +++++++ upload-and-download/sample-files/hello.txt | 1 + .../sample-files/subfolder/world.txt | 1 + upload-and-download/script-01.js | 38 +++++++++++++++++++ upload-and-download/script-02.js | 36 ++++++++++++++++++ website/.env.example | 4 ++ website/.gitignore | 2 + website/package.json | 13 +++++++ 22 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 dynamic-content/.env.example create mode 100644 filesystem/.env.example create mode 100644 multi-author-blog/.env.example create mode 100644 routing-manifest/.env.example create mode 100644 routing/.env.example create mode 100644 simple-blog/.env.example create mode 100644 upload-and-download/.env.example create mode 100644 upload-and-download/.gitignore create mode 100644 upload-and-download/package.json create mode 100644 upload-and-download/sample-files/hello.txt create mode 100644 upload-and-download/sample-files/subfolder/world.txt create mode 100644 upload-and-download/script-01.js create mode 100644 upload-and-download/script-02.js create mode 100644 website/.env.example create mode 100644 website/.gitignore create mode 100644 website/package.json diff --git a/dynamic-content/.env.example b/dynamic-content/.env.example new file mode 100644 index 0000000..7dd2f5f --- /dev/null +++ b/dynamic-content/.env.example @@ -0,0 +1,2 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= diff --git a/dynamic-content/package.json b/dynamic-content/package.json index b88a843..455716d 100644 --- a/dynamic-content/package.json +++ b/dynamic-content/package.json @@ -3,6 +3,11 @@ "version": "1.0.0", "description": "Example scripts for the Dynamic Content guide — demonstrates immutability, feeds, and feed manifests.", "type": "module", + "scripts": { + "script:01": "node script-01.js", + "script:02": "node script-02.js", + "script:03": "node script-03.js" + }, "dependencies": { "@ethersphere/bee-js": "^9.1.1", "dotenv": "^16.4.7" diff --git a/filesystem/.env.example b/filesystem/.env.example new file mode 100644 index 0000000..3caf72a --- /dev/null +++ b/filesystem/.env.example @@ -0,0 +1,5 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= +UPLOAD_DIR=./folder +SCRIPT_02_MANIFEST= +SCRIPT_03_MANIFEST= diff --git a/filesystem/.gitignore b/filesystem/.gitignore index 3c3629e..37d7e73 100644 --- a/filesystem/.gitignore +++ b/filesystem/.gitignore @@ -1 +1,2 @@ node_modules +.env diff --git a/multi-author-blog/.env.example b/multi-author-blog/.env.example new file mode 100644 index 0000000..7dd2f5f --- /dev/null +++ b/multi-author-blog/.env.example @@ -0,0 +1,2 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= diff --git a/multi-author-blog/.gitignore b/multi-author-blog/.gitignore index 6e6904d..abf81bc 100644 --- a/multi-author-blog/.gitignore +++ b/multi-author-blog/.gitignore @@ -1,4 +1,5 @@ node_modules/ +.env config.json alice-posts.json bob-posts.json diff --git a/multi-author-blog/package.json b/multi-author-blog/package.json index b7260d0..28c7e0a 100644 --- a/multi-author-blog/package.json +++ b/multi-author-blog/package.json @@ -3,6 +3,13 @@ "version": "1.0.0", "description": "Example scripts for the Multi-Author Blog guide — demonstrates composable feeds where each author publishes independently and an admin aggregates posts into a homepage.", "type": "module", + "scripts": { + "init": "node init.js", + "add-post": "node add-post.js", + "update-index": "node update-index.js", + "add-author": "node add-author.js", + "read": "node read.js" + }, "dependencies": { "@ethersphere/bee-js": "^9.1.1", "dotenv": "^16.4.7" diff --git a/routing-manifest/.env.example b/routing-manifest/.env.example new file mode 100644 index 0000000..24f1a04 --- /dev/null +++ b/routing-manifest/.env.example @@ -0,0 +1,5 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= +PUBLISHER_KEY= +UPLOAD_DIR=./site +BASE_MANIFEST= diff --git a/routing-manifest/.gitignore b/routing-manifest/.gitignore index b512c09..1dcef2d 100644 --- a/routing-manifest/.gitignore +++ b/routing-manifest/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.env \ No newline at end of file diff --git a/routing/.env.example b/routing/.env.example new file mode 100644 index 0000000..9f301c3 --- /dev/null +++ b/routing/.env.example @@ -0,0 +1,4 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= +PUBLISHER_KEY= +UPLOAD_DIR=./dist diff --git a/routing/.gitignore b/routing/.gitignore index 76add87..a0d218e 100644 --- a/routing/.gitignore +++ b/routing/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +.env \ No newline at end of file diff --git a/simple-blog/.env.example b/simple-blog/.env.example new file mode 100644 index 0000000..7dd2f5f --- /dev/null +++ b/simple-blog/.env.example @@ -0,0 +1,2 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= diff --git a/upload-and-download/.env.example b/upload-and-download/.env.example new file mode 100644 index 0000000..7dd2f5f --- /dev/null +++ b/upload-and-download/.env.example @@ -0,0 +1,2 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= diff --git a/upload-and-download/.gitignore b/upload-and-download/.gitignore new file mode 100644 index 0000000..37d7e73 --- /dev/null +++ b/upload-and-download/.gitignore @@ -0,0 +1,2 @@ +node_modules +.env diff --git a/upload-and-download/package.json b/upload-and-download/package.json new file mode 100644 index 0000000..5b010c8 --- /dev/null +++ b/upload-and-download/package.json @@ -0,0 +1,14 @@ +{ + "name": "upload-and-download", + "version": "1.0.0", + "description": "Example scripts for the Upload and Download guide — demonstrates single-file upload/download and directory upload/download.", + "type": "module", + "scripts": { + "script:01": "node script-01.js", + "script:02": "node script-02.js" + }, + "dependencies": { + "@ethersphere/bee-js": "^9.1.1", + "dotenv": "^16.4.7" + } +} diff --git a/upload-and-download/sample-files/hello.txt b/upload-and-download/sample-files/hello.txt new file mode 100644 index 0000000..488722e --- /dev/null +++ b/upload-and-download/sample-files/hello.txt @@ -0,0 +1 @@ +Hello from Swarm! diff --git a/upload-and-download/sample-files/subfolder/world.txt b/upload-and-download/sample-files/subfolder/world.txt new file mode 100644 index 0000000..2a8d0a4 --- /dev/null +++ b/upload-and-download/sample-files/subfolder/world.txt @@ -0,0 +1 @@ +Hello from a subfolder! diff --git a/upload-and-download/script-01.js b/upload-and-download/script-01.js new file mode 100644 index 0000000..42f5d52 --- /dev/null +++ b/upload-and-download/script-01.js @@ -0,0 +1,38 @@ +/** + * script-01.js — Upload and download a single file + * + * Uploads a string as a named file, prints the Swarm reference, + * then downloads it back and prints the content. + * + * Usage: + * node script-01.js + */ + +import { Bee } from "@ethersphere/bee-js"; +import { config } from "dotenv"; +config(); + +if (!process.env.BEE_URL || !process.env.BATCH_ID) { + console.error("Error: BEE_URL and BATCH_ID must be set in .env"); + console.error("Copy .env.example to .env and fill in your values."); + process.exit(1); +} + +const bee = new Bee(process.env.BEE_URL); +const batchId = process.env.BATCH_ID; + +// Upload a single file +const upload = await bee.uploadFile(batchId, "Hello Swarm!", "hello.txt", { + contentType: "text/plain", +}); + +console.log("Uploaded reference:", upload.reference.toHex()); +console.log("URL:", `${process.env.BEE_URL}/bzz/${upload.reference.toHex()}`); + +// Download it back by reference +const file = await bee.downloadFile(upload.reference); + +console.log("\nDownloaded:"); +console.log(" name:", file.name); +console.log(" content-type:", file.contentType); +console.log(" content:", file.data.toUtf8()); diff --git a/upload-and-download/script-02.js b/upload-and-download/script-02.js new file mode 100644 index 0000000..7b98cc5 --- /dev/null +++ b/upload-and-download/script-02.js @@ -0,0 +1,36 @@ +/** + * script-02.js — Upload a directory and download files by path + * + * Uploads the sample-files/ directory as a collection (Swarm manifest), + * then downloads individual files using their relative paths. + * + * Usage: + * node script-02.js + */ + +import { Bee } from "@ethersphere/bee-js"; +import { config } from "dotenv"; +config(); + +if (!process.env.BEE_URL || !process.env.BATCH_ID) { + console.error("Error: BEE_URL and BATCH_ID must be set in .env"); + console.error("Copy .env.example to .env and fill in your values."); + process.exit(1); +} + +const bee = new Bee(process.env.BEE_URL); +const batchId = process.env.BATCH_ID; + +// Upload the sample-files directory as a collection +const upload = await bee.uploadFilesFromDirectory(batchId, "./sample-files"); +const ref = upload.reference.toHex(); + +console.log("Uploaded collection:", ref); +console.log("URL:", `${process.env.BEE_URL}/bzz/${ref}/`); + +// Download individual files by their relative paths +const hello = await bee.downloadFile(upload.reference, "hello.txt"); +console.log("\nhello.txt:", hello.data.toUtf8()); + +const world = await bee.downloadFile(upload.reference, "subfolder/world.txt"); +console.log("subfolder/world.txt:", world.data.toUtf8()); diff --git a/website/.env.example b/website/.env.example new file mode 100644 index 0000000..00eab6a --- /dev/null +++ b/website/.env.example @@ -0,0 +1,4 @@ +BEE_URL=http://localhost:1633 +BATCH_ID= +PUBLISHER_KEY= +UPLOAD_DIR=./ diff --git a/website/.gitignore b/website/.gitignore new file mode 100644 index 0000000..37d7e73 --- /dev/null +++ b/website/.gitignore @@ -0,0 +1,2 @@ +node_modules +.env diff --git a/website/package.json b/website/package.json new file mode 100644 index 0000000..0aa182e --- /dev/null +++ b/website/package.json @@ -0,0 +1,13 @@ +{ + "name": "website", + "version": "1.0.0", + "description": "Example static website for the Host a Webpage guide.", + "type": "module", + "scripts": { + "upload": "node upload.js" + }, + "dependencies": { + "@ethersphere/bee-js": "^9.1.1", + "dotenv": "^16.4.7" + } +} From 411af26a17652eed9e9a13bf36a5d3935aff86c1 Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Tue, 26 May 2026 16:28:45 +0700 Subject: [PATCH 2/3] fix: resolve upload script and .env.example issues across examples - Move website static files into site/ subdirectory so UPLOAD_DIR is unambiguous - Remove dotenv import from utils/upload-site.js (was breaking ESM resolution since utils/ has no node_modules); callers now own dotenv.config() - Add dotenv.config() to website/upload.js and routing/upload.js - Add dotenv dep, "type": "module", and upload npm script to routing/package.json - Remove dead PUBLISHER_KEY from routing/.env.example and routing-manifest/.env.example Co-Authored-By: Claude Sonnet 4.6 --- routing-manifest/.env.example | 1 - routing/.env.example | 1 - routing/package-lock.json | 13 + routing/package.json | 5 +- routing/upload.js | 3 + upload-and-download/package-lock.json | 396 ++++++++++++++++++++++++++ utils/upload-site.js | 3 - website/.env.example | 2 +- website/package-lock.json | 396 ++++++++++++++++++++++++++ website/{ => site}/404.html | 0 website/{ => site}/favicon.svg | 0 website/{ => site}/index.html | 0 website/{ => site}/robots.txt | 0 website/{ => site}/styles.css | 0 website/upload.js | 3 + 15 files changed, 816 insertions(+), 7 deletions(-) create mode 100644 upload-and-download/package-lock.json create mode 100644 website/package-lock.json rename website/{ => site}/404.html (100%) rename website/{ => site}/favicon.svg (100%) rename website/{ => site}/index.html (100%) rename website/{ => site}/robots.txt (100%) rename website/{ => site}/styles.css (100%) diff --git a/routing-manifest/.env.example b/routing-manifest/.env.example index 24f1a04..d699144 100644 --- a/routing-manifest/.env.example +++ b/routing-manifest/.env.example @@ -1,5 +1,4 @@ BEE_URL=http://localhost:1633 BATCH_ID= -PUBLISHER_KEY= UPLOAD_DIR=./site BASE_MANIFEST= diff --git a/routing/.env.example b/routing/.env.example index 9f301c3..90fdba3 100644 --- a/routing/.env.example +++ b/routing/.env.example @@ -1,4 +1,3 @@ BEE_URL=http://localhost:1633 BATCH_ID= -PUBLISHER_KEY= UPLOAD_DIR=./dist diff --git a/routing/package-lock.json b/routing/package-lock.json index 9c9d995..253baf9 100644 --- a/routing/package-lock.json +++ b/routing/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@ethersphere/bee-js": "^9.8.1", + "dotenv": "^16.4.7", "react": "^19.1.1", "react-dom": "^19.1.1", "react-router-dom": "^7.9.6" @@ -910,6 +911,18 @@ "node": ">=0.4.0" } }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", diff --git a/routing/package.json b/routing/package.json index b5ef702..639d759 100644 --- a/routing/package.json +++ b/routing/package.json @@ -1,13 +1,16 @@ { "name": "swarm-routing", "version": "1.0.0", + "type": "module", "scripts": { "start": "vite", "build": "vite build --base=./", - "check": "tsc --noEmit" + "check": "tsc --noEmit", + "upload": "node upload.js" }, "license": "ISC", "dependencies": { + "dotenv": "^16.4.7", "@ethersphere/bee-js": "^9.8.1", "react": "^19.1.1", "react-dom": "^19.1.1", diff --git a/routing/upload.js b/routing/upload.js index d0d06eb..e726159 100644 --- a/routing/upload.js +++ b/routing/upload.js @@ -1,3 +1,6 @@ +import dotenv from "dotenv"; +dotenv.config(); + import { uploadToSwarm } from "../utils/upload-site.js"; uploadToSwarm(); diff --git a/upload-and-download/package-lock.json b/upload-and-download/package-lock.json new file mode 100644 index 0000000..485c33f --- /dev/null +++ b/upload-and-download/package-lock.json @@ -0,0 +1,396 @@ +{ + "name": "upload-and-download", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "upload-and-download", + "version": "1.0.0", + "dependencies": { + "@ethersphere/bee-js": "^9.1.1", + "dotenv": "^16.4.7" + } + }, + "node_modules/@ethersphere/bee-js": { + "version": "9.8.1", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-9.8.1.tgz", + "integrity": "sha512-crOjFHYPdQPG1ty2KTO5b7spIGRVb6MLucC8KOyUsPk72XYCQLf0FZl8mwKAozqZd6NLOOPZw8E/ftjoz7zYJQ==", + "license": "BSD-3-Clause", + "dependencies": { + "axios": "^0.30.0", + "cafe-utility": "^31.0.0", + "debug": "^4.4.1", + "isomorphic-ws": "^4.0.1", + "semver": "^7.3.5", + "ws": "^8.7.0" + }, + "engines": { + "bee": "2.4.0-390a402e", + "beeApiVersion": "7.2.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.30.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.30.3.tgz", + "integrity": "sha512-5/tmEb6TmE/ax3mdXBc/Mi6YdPGxQsv+0p5YlciXWt3PHIn0VamqCXhRMtScnwY3lbgSXLneOuXAKUhgmSRpwg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.4", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/cafe-utility": { + "version": "31.1.1", + "resolved": "https://registry.npmjs.org/cafe-utility/-/cafe-utility-31.1.1.tgz", + "integrity": "sha512-1GZGghv6wi5Yfb6DGR02aIwPKH1/ny9w8nlUZM0Mo+dUf0BpmPmy9wKMZZEeaY72LPmDWQtfyoGGgaG5kINsNw==", + "license": "MIT" + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz", + "integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/utils/upload-site.js b/utils/upload-site.js index f29971d..60d0a8e 100644 --- a/utils/upload-site.js +++ b/utils/upload-site.js @@ -1,8 +1,5 @@ -import dotenv from "dotenv"; import { Bee, NULL_TOPIC, PrivateKey } from "@ethersphere/bee-js"; -dotenv.config(); - export async function uploadToSwarm() { const bee = new Bee(process.env.BEE_URL); const key = new PrivateKey(process.env.PUBLISHER_KEY); diff --git a/website/.env.example b/website/.env.example index 00eab6a..dafe308 100644 --- a/website/.env.example +++ b/website/.env.example @@ -1,4 +1,4 @@ BEE_URL=http://localhost:1633 BATCH_ID= PUBLISHER_KEY= -UPLOAD_DIR=./ +UPLOAD_DIR=./site diff --git a/website/package-lock.json b/website/package-lock.json new file mode 100644 index 0000000..733312a --- /dev/null +++ b/website/package-lock.json @@ -0,0 +1,396 @@ +{ + "name": "website", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "website", + "version": "1.0.0", + "dependencies": { + "@ethersphere/bee-js": "^9.1.1", + "dotenv": "^16.4.7" + } + }, + "node_modules/@ethersphere/bee-js": { + "version": "9.8.1", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-9.8.1.tgz", + "integrity": "sha512-crOjFHYPdQPG1ty2KTO5b7spIGRVb6MLucC8KOyUsPk72XYCQLf0FZl8mwKAozqZd6NLOOPZw8E/ftjoz7zYJQ==", + "license": "BSD-3-Clause", + "dependencies": { + "axios": "^0.30.0", + "cafe-utility": "^31.0.0", + "debug": "^4.4.1", + "isomorphic-ws": "^4.0.1", + "semver": "^7.3.5", + "ws": "^8.7.0" + }, + "engines": { + "bee": "2.4.0-390a402e", + "beeApiVersion": "7.2.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.30.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.30.3.tgz", + "integrity": "sha512-5/tmEb6TmE/ax3mdXBc/Mi6YdPGxQsv+0p5YlciXWt3PHIn0VamqCXhRMtScnwY3lbgSXLneOuXAKUhgmSRpwg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.4", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/cafe-utility": { + "version": "31.1.1", + "resolved": "https://registry.npmjs.org/cafe-utility/-/cafe-utility-31.1.1.tgz", + "integrity": "sha512-1GZGghv6wi5Yfb6DGR02aIwPKH1/ny9w8nlUZM0Mo+dUf0BpmPmy9wKMZZEeaY72LPmDWQtfyoGGgaG5kINsNw==", + "license": "MIT" + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz", + "integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/website/404.html b/website/site/404.html similarity index 100% rename from website/404.html rename to website/site/404.html diff --git a/website/favicon.svg b/website/site/favicon.svg similarity index 100% rename from website/favicon.svg rename to website/site/favicon.svg diff --git a/website/index.html b/website/site/index.html similarity index 100% rename from website/index.html rename to website/site/index.html diff --git a/website/robots.txt b/website/site/robots.txt similarity index 100% rename from website/robots.txt rename to website/site/robots.txt diff --git a/website/styles.css b/website/site/styles.css similarity index 100% rename from website/styles.css rename to website/site/styles.css diff --git a/website/upload.js b/website/upload.js index d0d06eb..e726159 100644 --- a/website/upload.js +++ b/website/upload.js @@ -1,3 +1,6 @@ +import dotenv from "dotenv"; +dotenv.config(); + import { uploadToSwarm } from "../utils/upload-site.js"; uploadToSwarm(); From 52677da34d079843ef515eba5474668a8876d961 Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Tue, 26 May 2026 17:22:59 +0700 Subject: [PATCH 3/3] docs: add READMEs linking each example folder to its guide Add or refresh README.md in each example folder so anyone landing on the folder via GitHub gets a one-screen orientation and a link back to the corresponding guide on docs.ethswarm.org. Covers upload-and-download, filesystem, routing, routing-manifest, dynamic-content, simple-blog, multi-author-blog, and the existing website example. --- dynamic-content/README.md | 33 +++++++++++++++++++++++ filesystem/README.md | 35 ++++++++++++++++++++++++ multi-author-blog/README.md | 38 ++++++++++++++++++++++++++ routing-manifest/README.md | 50 ++++++++++++++++++++++------------- routing/README.md | 34 ++++++++++++++++++++++++ simple-blog/README.md | 37 ++++++++++++++++++++++++++ upload-and-download/README.md | 29 ++++++++++++++++++++ website/README.md | 34 +++++++++++++++++------- 8 files changed, 263 insertions(+), 27 deletions(-) create mode 100644 dynamic-content/README.md create mode 100644 filesystem/README.md create mode 100644 multi-author-blog/README.md create mode 100644 routing/README.md create mode 100644 simple-blog/README.md create mode 100644 upload-and-download/README.md diff --git a/dynamic-content/README.md b/dynamic-content/README.md new file mode 100644 index 0000000..b4bb4de --- /dev/null +++ b/dynamic-content/README.md @@ -0,0 +1,33 @@ +# Dynamic Content (Feeds) + +Companion code for the [**Dynamic Content**](https://docs.ethswarm.org/docs/develop/dynamic-content) guide. Demonstrates feeds — Swarm's mutable-pointer layer on top of immutable storage — through three small scripts. + +For the complete blog project that puts these concepts together, see the [`simple-blog/`](../simple-blog) example. + +## What it does + +- `script-01.js` — the immutability problem: uploading the same content twice with a small change produces different hashes +- `script-02.js` — write a Swarm reference to a feed, read it back, then update the feed with new content +- `script-03.js` — wrap a feed in a feed manifest to get a stable URL that always resolves to the latest entry + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL and BATCH_ID in .env +``` + +## Run + +```bash +npm run script:01 +npm run script:02 +npm run script:03 +``` + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded **immutable** postage stamp batch (feeds break on mutable batches when they fill up) +- Node.js 18+ diff --git a/filesystem/README.md b/filesystem/README.md new file mode 100644 index 0000000..787c1a8 --- /dev/null +++ b/filesystem/README.md @@ -0,0 +1,35 @@ +# Filesystem (Manage Files) + +Companion code for the [**Manage Files**](https://docs.ethswarm.org/docs/develop/files) guide. Demonstrates how manifests provide filesystem-like behavior on Swarm — inspecting a manifest, adding a file without re-uploading, and moving a file by remapping a path. + +## What it does + +- `script-01.js` — uploads `./folder/` and prints the resulting manifest tree +- `script-02.js` — adds a new file (`new.txt`) to the existing manifest without re-uploading the directory +- `script-03.js` — moves `new.txt` from the root to `nested/deeper/new.txt` by editing the manifest + +Each script prints a new manifest reference. You'll feed the reference from each step into the next via the `SCRIPT_*_MANIFEST` env vars. + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL, BATCH_ID, and UPLOAD_DIR in .env +``` + +## Run + +```bash +node script-01.js +# Copy the printed manifest reference into SCRIPT_02_MANIFEST in .env +node script-02.js +# Copy the new manifest reference into SCRIPT_03_MANIFEST in .env +node script-03.js +``` + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded postage stamp batch +- Node.js 18+ diff --git a/multi-author-blog/README.md b/multi-author-blog/README.md new file mode 100644 index 0000000..4938e85 --- /dev/null +++ b/multi-author-blog/README.md @@ -0,0 +1,38 @@ +# Multi-Author Blog + +Companion code for the [**Multi-Author Blog**](https://docs.ethswarm.org/docs/develop/multi-author-blog) guide. Extends the [simple-blog](../simple-blog) pattern into a multi-author system: each author independently controls their own feed, and an admin maintains a master index feed that links them all together — feeds referencing other feeds. + +## What it does + +- `init.js` — one-time setup: generates keys for admin + initial authors, creates per-author feeds and a master index feed +- `add-post.js "" "<body>"` — author publishes a new post to their feed +- `update-index.js` — admin reads all author feeds, aggregates them into a homepage, and publishes the homepage feed +- `add-author.js <name>` — admin adds a new author (new key, new per-author feed, appended to the index) +- `read.js` — reads the index and every author's latest post without needing private keys + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL and BATCH_ID in .env +``` + +## Run (full flow) + +```bash +npm run init +npm run add-post -- alice "Hello from Alice" "Alice's first post." +npm run add-post -- bob "Hello from Bob" "Bob's first post." +npm run update-index +npm run read +npm run add-author -- charlie +``` + +`init.js` writes keys, manifest hashes, and per-author post lists to local JSON files. + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded **immutable** postage stamp batch +- Node.js 18+ diff --git a/routing-manifest/README.md b/routing-manifest/README.md index 65cb6df..37fa1b1 100644 --- a/routing-manifest/README.md +++ b/routing-manifest/README.md @@ -1,25 +1,39 @@ -# Swarm Routing Demo (Strategy A) +# Routing (Manifest-Based) -This is a minimal static website intended for **Manifest-Based Routing** with **Strategy A (aliases)**. +Companion code for the [**Website Routing**](https://docs.ethswarm.org/docs/develop/routing#manifest-based-routing) guide's manifest-based routing section. Adds clean URLs (e.g. `/about` resolving to `/about.html`) by editing the manifest directly — no React, no client-side router. -## What it includes -- `index.html`, `about.html`, `contact.html` -- `404.html` (for `errorDocument`) -- `new-page.html` (for "redirect-like" remapping) -- `assets/` (CSS + a tiny nav helper) +For the hash-routing approach using `HashRouter` in a React SPA, see [`routing/`](../routing). -## How it maps to your guide -Upload the `site/` folder with: +## What it does -```ts -const { reference } = await bee.uploadFilesFromDirectory(batchId, "./site", { - indexDocument: "index.html", - errorDocument: "404.html" -}); +- `upload.js` — uploads `./site/` with `indexDocument: index.html` and `errorDocument: 404.html` +- `updateManifest.js` — adds manifest forks so `/about` and `/about/` resolve to the same content as `/about.html` +- `removeAndAddRoutes.js` — removes the old `/about*` routes and adds `/moved-about` aliases (demonstrates that routes are mutable through manifest edits) + +Each script prints a new manifest reference. Set `BASE_MANIFEST` in `.env` to the reference from the previous step before running the next. + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL and BATCH_ID in .env ``` -Then, in your manifest manipulation step, add aliases like: -- `about` and `about/` → the same entry as `about.html` -- `contact` and `contact/` → the same entry as `contact.html` +## Run + +```bash +node upload.js +# Copy the printed manifest reference into BASE_MANIFEST in .env +node updateManifest.js +# Copy the new reference into BASE_MANIFEST +node removeAndAddRoutes.js +``` + +Verify by opening `http://localhost:1633/bzz/<REFERENCE>/about` in your browser at each step. + +## Requirements -This allows clean URLs without changing the file structure. +- A running Bee node (default: `http://localhost:1633`) +- A funded postage stamp batch +- Node.js 18+ diff --git a/routing/README.md b/routing/README.md new file mode 100644 index 0000000..daded9c --- /dev/null +++ b/routing/README.md @@ -0,0 +1,34 @@ +# Routing (Hash-Based Client-Side) + +Companion code for the [**Website Routing**](https://docs.ethswarm.org/docs/develop/routing) guide. A minimal Vite + React app using `HashRouter` to give a Swarm-hosted site clean, hash-based URLs (e.g. `/#/about`) that work without any server-side routing. + +For the manifest-based routing approach (no React, server-side-style URLs via manifest edits), see the [`routing-manifest/`](../routing-manifest) example. + +## What it does + +- Builds a small SPA with Home, About, and NotFound pages +- Builds to `./dist/` via Vite +- `upload.js` uploads `./dist/` to Swarm and publishes the result as a feed entry (stable URL across re-uploads) + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL, BATCH_ID, and PUBLISHER_KEY in .env +``` + +## Build and upload + +```bash +npm run build # Vite build into ./dist +npm run upload # Upload ./dist to Swarm and publish to a feed +``` + +The upload prints two hashes: the website reference and a feed manifest. Open the feed manifest URL (`http://localhost:1633/bzz/<FEED_MANIFEST>/`) in a browser. `/#/about` should resolve to the About page. + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded postage stamp batch +- Node.js 18+ diff --git a/simple-blog/README.md b/simple-blog/README.md new file mode 100644 index 0000000..356245d --- /dev/null +++ b/simple-blog/README.md @@ -0,0 +1,37 @@ +# Simple Blog + +Companion code for the [**Dynamic Content**](https://docs.ethswarm.org/docs/develop/dynamic-content#example-project--simple-blog) guide's example project. A single-author blog built on a Swarm feed: each post regenerates the full blog HTML and publishes it as the next feed entry, while the feed manifest URL stays stable. + +For the multi-author extension (authors with their own feeds + a shared index feed), see [`multi-author-blog/`](../multi-author-blog). + +## What it does + +- `init.js` — generates a publisher key, creates an empty blog, publishes it to a feed, and prints the feed manifest URL +- `post.js create <slug> "<title>" "<body>"` — adds a new post and publishes the updated blog +- `post.js edit <slug> "<title>" "<body>"` — replaces an existing post and re-publishes +- `post.js delete <slug>` — removes a post and re-publishes +- `read.js` — reads the latest feed entry without needing a private key + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL and BATCH_ID in .env +``` + +## Run + +```bash +npm run init +npm run post -- create hello "Hello Swarm" "This is my first post." +npm run read +``` + +`init.js` writes the generated publisher key, posts list, and config to local JSON files alongside the scripts. + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded **immutable** postage stamp batch +- Node.js 18+ diff --git a/upload-and-download/README.md b/upload-and-download/README.md new file mode 100644 index 0000000..4078f64 --- /dev/null +++ b/upload-and-download/README.md @@ -0,0 +1,29 @@ +# Upload and Download + +Companion code for the [**Upload and Download**](https://docs.ethswarm.org/docs/develop/upload-and-download) guide. The first step in the Swarm developer guide series — uploading a file or directory and downloading it back through your Bee node. + +## What it does + +- `script-01.js` — uploads a single string as `hello.txt`, downloads it back, and prints the content +- `script-02.js` — uploads the `./sample-files/` directory and retrieves files by path (including from a subfolder) + +## Setup + +```bash +npm install +cp .env.example .env +# Fill in BEE_URL and BATCH_ID in .env +``` + +## Run + +```bash +npm run script:01 +npm run script:02 +``` + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded postage stamp batch +- Node.js 18+ diff --git a/website/README.md b/website/README.md index 4a702de..d141296 100644 --- a/website/README.md +++ b/website/README.md @@ -1,14 +1,30 @@ -# Swarm + ENS Starter +# Website (Host a Webpage) -This is a minimal static website intended as a starting point for hosting content on Swarm and resolving it through an ENS name. +Companion code for the [**Host a Webpage**](https://docs.ethswarm.org/docs/develop/host-your-website) guide. A minimal static website with an `upload.js` that uploads the site to Swarm and publishes the resulting reference to a feed (so your URL stays stable across re-uploads). -For detailed instructions on how to upload and configure ENS, see the Bee documentation. +## What it does -## Files +- `site/` contains the static files to upload (`index.html`, `404.html`, `styles.css`, `robots.txt`, `favicon.svg`) +- `upload.js` uploads `site/` to Swarm and publishes the result as a feed entry -- `index.html` — main landing page -- `404.html` — error page displayed when content is not found -- `styles.css` — minimal styling -- `robots.txt` — default robots configuration -- `favicon.svg` — site icon +## Setup +```bash +npm install +cp .env.example .env +# Fill in BEE_URL, BATCH_ID, and PUBLISHER_KEY in .env +``` + +## Run + +```bash +npm run upload +``` + +You'll get two hashes: the website Swarm hash and a feed manifest hash. Open the feed manifest URL (`http://localhost:1633/bzz/<FEED_MANIFEST>/`) in your browser, or use the feed manifest as your ENS content hash. + +## Requirements + +- A running Bee node (default: `http://localhost:1633`) +- A funded **immutable** postage stamp batch (mutable batches break feeds when they fill up) +- Node.js 18+