This project is a simple web-based Todo list with register/login, built with Vue on the frontend and Cloudflare Workers + D1 on the backend for deployment.
backend/Go REST API (legacy local dev)backend/sql/schema.sqlMySQL schema (legacy)frontend/Vue 3 single-page UIworker/Cloudflare Workers API (TypeScript)worker/sql/schema.sqlD1 schema
- Create a MySQL database and apply the schema:
SOURCE backend/sql/schema.sql;
- Set environment variables:
export DB_DSN="user:password@tcp(127.0.0.1:3306)/todolist?parseTime=true" export SERVER_ADDR=":8080" export TOKEN_TTL_HOURS="72"
- Start the API:
cd backend go run main.go
- Install dependencies:
cd worker npm install - Create a D1 database:
Copy the
npx wrangler d1 create todolist-db
database_idintoworker/wrangler.toml. - Apply the schema:
npx wrangler d1 execute todolist-db --file=sql/schema.sql
- Local dev:
The API will be available at
npx wrangler dev
http://localhost:8787. - Deploy:
npx wrangler deploy
- Install dependencies:
cd frontend npm install - Start the dev server:
npm run dev
- Open the URL printed in the terminal (usually
http://localhost:5173). - Point the frontend at your deployed Worker by setting:
VITE_API_BASE="https://your-worker.your-subdomain.workers.dev"
POST /api/register{ "username": "", "password": "" }POST /api/login{ "username": "", "password": "" }->{ "token": "" }GET /api/todos(Bearer token)POST /api/todos{ "title": "" }PUT /api/todos/:id{ "title": "", "done": true }DELETE /api/todos/:id