CloudFlare Worker for Dashy Backup and Restore
February 27, 2024 ยท View on GitHub
This is the code for the backup / restore server used by Dashy. For more info, see Dashy Cloud Sync Docs.
All data needs to be encrypted before being sent to the backend. In Dashy, this is done in CloudBackup.js, using crypto.js's AES method, using the users chosen password as the key.
Getting Started
- Install Wrangler CLI Tool:
npm i -g @cloudflare/wrangler - Log into Cloudflare account:
wrangler login - Create a new project:
wrangler generate my-project - Install dependencies:
cd my-project&&npm i - Populate
wrangler.toml
- Add your
account_id(found on the right sidebar of the Workers or Overview Dashboard) - Add your
zone_id(found in the Overview tab of your desired domain on Cloudflare) - Add your
route, which should be a domain or host, supporting a wildcard
- Populate
index.jswith your code to handle requests - To start the development server, run
wrangler dev - Finally, when you're ready to publish it, run
wrangler publish
Endpoints
GET- Get config for a given userbackupId- The ID of the desired encrypted objectsubHash- The latter half of the password hash, to verify ownership
POST- Save a new config object, and returnsbackupIduserData- The encrypted, compressed and stringified user configsubHash- The latter half of the password hash, to verify ownership
PUT- Update an existing config objectbackupId- The ID of the object to updatesubHash- Part of the hash, to verify ownership of said objectuserData- The new data to store
DELETE- Delete a specified config objectbackupId- The ID of the object to be deletedsubHash- Part of the password hash, to verify ownership of the object
For more details on using these endpoints, see the API Docs or import the Postman collection.