This tutorial will guide you step by step from scratch on how to develop your own API service using Cloudflare Workers.
Preview: https://life.littleeleven.com
Recommended to use pnpm to install dependencies
pnpm installRelated documentation: https://developers.cloudflare.com/workers/wrangler/commands/#d1
Set the d1_database field in wrangler.toml to your database information (required)
Example:
d1_databases = [ { binding = "DB", database_name = "littleeleven", database_id = "c6ca0e33-ea58-48d3-b779-a21f9a063812" }, ]Sync the sql files of drizzle, execute the following command (required)
wrangler d1 migrations apply littleeleven --localRelated documentation: https://developers.cloudflare.com/workers/wrangler/commands/#secret
wrangler secret put JWT_SECRET
wrangler secret put GOOGLE_ID
wrangler secret put GOOGLE_SECRET
wrangler secret put GITHUB_ID
wrangler secret put GITHUB_SECRET
wrangler secret put DISCORD_ID
wrangler secret put DISCORD_SECRETExecute the following command to start the local development server
# run your Worker in an ideal development workflow (with a local server, file watcher & more)
pnpm run start:localpnpm run unit:testpnpm run e2e:test# deploy your Worker globally to the Cloudflare network (update your wrangler.toml file for configuration)
pnpm run deploy