Cloudflare Workers provides a serverless execution environment that allows you to create new applications or augment existing ones without configuring or maintaining infrastructure.

Wrangler Link to heading

The Cloudflare Developer Platform command-line interface (CLI), allows you to manage Worker projects.

  • npm install wrangler –save-dev
  • npx wrangler -v
  • npm install wrangler@latest
  • npm create cloudflare@latest – worker-project-name
  • npm run dev/npx wrangler dev
  • npm run cf-typegen
  • npx wrangler deploy

D1 database Link to heading

D1 is Cloudflare’s managed, serverless database with SQLite’s SQL semantics, built-in disaster recovery, and Worker and HTTP API access.

  • npx wrangler d1 create your-database-name
  • npx wrangler d1 execute your-database-name –command <SQL_QUERY> –remote
  • npx wrangler d1 execute your-database-name –command <SQL_QUERY> –local
  • npx wrangler d1 execute your-database-name –file=./schemas/schema.sql
  • npx wrangler d1 migrations apply your-database-name –local/remote
  • npx wrangler d1 execute your-database-name –command <SQL_QUERY> –local/remote

Prisma ORM Link to heading

  • npm install prisma –save-dev
  • npm install @prisma/client
  • npm install @prisma/adapter-d1
  • npx prisma init –datasource-provider sqlite
  • npx wrangler d1 migrations create your-database-name your-table-name
  • npx prisma migrate diff –from-empty –to-schema-datamodel ./prisma/schema.prisma –script –output migrations/<MIGRATION_NAME>.sql
  • npx prisma generate

R2 bucket Link to heading

Cloudflare R2 Storage allows developers to store large amounts of unstructured data without the costly egress bandwidth fees associated with typical cloud storage services.

  • npx wrangler r2 bucket create <BUCKET_NAME>