Skip to content

Latest commit

 

History

History
83 lines (53 loc) · 1.47 KB

README.md

File metadata and controls

83 lines (53 loc) · 1.47 KB

E-Commerce Worker

This Workers script sends emails using the Resend API. It uses Cloudflare Queue to decouple sending emails.

Features

  • Email sending functionality using Resend
  • Multiple email templates (Sign In, Sign Up, Order Confirmation)
  • Queue-based email sending

Getting Started

Prerequisites

  • Cloudflare Workers account
  • Resend API key

Setting up the project

  1. Install the project dependencies:
# make sure you are in the correct directory
# cd server
npm install
  1. Set the Resend API key
  • Rename .dev.vars.example to .dev.vars
  • Replace re_1234567890 with your Resend API key
  1. Create a D1 database
npx wrangler d1 create e-com
  1. Update the bindings
  • Update the [[d1_database]] binding in wrangler.toml
  1. Create tables
npx wrangler d1 execute e-com --file="./schema/init.sql"
  1. Create a queue
# Creat Queue to handle orders
npx wrangler queues create order-queue-demo

# Create Queue to handle user sessions
npx wrangler queues create user-session-queue-demo

Local Development

Start the local development server:

npm run dev

Deployment

  1. Add table to the remote database
npx wrangler d1 execute e-com --file="./schema/init.sql" --remote
  1. Deploy the project to Cloudflare Workers:
npm run deploy

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.