JSONBin
Simple JSON as Storage service deployed on Cloudflare Workers.
Deploy this following code to Cloudflare Workers
https://github.com/theowenyoung/blog/blob/main/scripts/jsonbin/main.js
See How to deploy
Write JSON
curl 'https://json.owenyoung.com/foo/bar?key=abc' --data '{"foo":"bar"}'
Read JSON
curl 'https://json.owenyoung.com/foo/bar?key=abc'
Usage
import JSONBin from "https://deno.land/x/jsonbin@v0.0.4/mod.ts";
const jsonBin = new JSONBin({
api: "https://json.owenyoung.com",
key: "abc",
});
const sentArr = await jsonBin.get("/rss/abc", []);
console.log("current sentArr", sentArr);
// do some work
// ...
sentArr.push("456");
// write the newest sentArr to KV
await jsonBin.set("/rss/abc", sentArr);
How
- Create a KV namespane on Cloudfalre with name
jsonbin
- Create a worker on Cloudfalre, bind the KV at Settings -> Variables -> KV Namespace Bindings ,
name:
JSONBIN`. - Quick Edit worker code, with https://github.com/theowenyoung/blog/blob/main/scripts/jsonbin/main.js , change the APIKEY, save it.
- You can add a custom domai for it.