This project provides a JSON Database based on Cloudflare Workers deployment. You can easily store and read JSON data.
Use POST to write sample data {"hello": "world"}
to namespace demo_bucket/hello
.
curl -X "POST" "https://jsonbase.huhuhang.workers.dev/demo_bucket/hello" \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"hello": "world"}'
Get data for namespace demo_bucket/hello
using GET method.
curl "https://jsonbase.huhuhang.workers.dev/demo_bucket/hello"
Returns.
{"hello": "world"}
You can create a new project directly in Cloudflare Workers web version and copy index.js
from this repository to the online editor to deploy it.
You also need to create a KV database and bind to Cloudflare Workers.
or use the official wrangler cli tool provided by.
-
learn how to use the Cloudflare Workers command line tool wrangler.
-
initialize a new project based on this project.
wrangler generate jsonbase https://github.com/huhuhang/jsonbase
-
modify the reserved
account_id
inwrangler.toml
and replace it with your account information. 4. -
Modify the KV database
id
reserved inwrangler.toml
and replace it with your account information. -
Add the
jsonbase
project to the Cloudflare Workers deployment.
Currently there is no authentication added, to secure your data, you can use Cloudflare Access to create a request policy. Or refer to official example to modify the code to add authentication module. Please do not use the sample database in the project in production environment, your data may be removed or tampered with, please deploy it yourself.