Skip to content

chythram05/quest-list-worker1

Repository files navigation

Quest List

Deploy to Cloudflare

A fun Cloudflare Workers todo app using all three storage primitives:

  • D1 stores todos.
  • KV stores app preferences like the selected theme and daily vibe.
  • R2 stores optional todo attachments.

Setup

Install dependencies:

npm install

For deploy-button users, Cloudflare can provision D1, KV, and R2 automatically from wrangler.toml.

For manual setup, create Cloudflare resources:

wrangler d1 create quest-list-worker-TODO_DB
wrangler kv namespace create TODO_KV
wrangler r2 bucket create quest-list-worker-todo-bucket

Copy the generated D1 database ID, KV namespace ID, and R2 bucket name into wrangler.toml if you are not using automatic provisioning.

Create the database tables locally:

npm run db:migrate:local

For production, run the remote migration too:

npm run db:migrate:remote

Add the admin secret:

wrangler secret put ADMIN_TOKEN

For local development, copy .dev.vars.example to .dev.vars and change the token:

ADMIN_TOKEN=pick-a-local-secret

Run locally:

npm run dev

Deploy:

npm run deploy

API

  • GET / serves the app.
  • GET /api/config returns app config, current theme, daily vibe, and upload limit.
  • GET /api/todos lists todos.
  • POST /api/todos creates a todo.
  • PATCH /api/todos/:id updates a todo.
  • DELETE /api/todos/:id deletes a todo and its R2 attachment.
  • POST /api/todos/:id/attachment uploads an attachment to R2 with multipart field file.
  • GET /api/todos/:id/attachment downloads an attachment from R2.
  • DELETE /api/todos/:id/attachment removes an attachment from R2.
  • POST /api/theme stores the selected theme in KV.
  • GET /api/admin/stats returns protected stats when called with Authorization: Bearer <ADMIN_TOKEN>.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages