Skip to content

zane-ops/cdn

Repository files navigation

Worker + D1 Database

Deploy to Cloudflare

Worker + D1 Template Preview

D1 is Cloudflare's native serverless SQL database (docs). This project demonstrates using a Worker with a D1 binding to execute a SQL statement. A simple frontend displays the result of this query:

Getting Started

Outside of this repo, you can start a new project with this template using C3 (the create-cloudflare CLI):

npm create cloudflare@latest -- --template=cloudflare/templates/d1-template

A live public deployment of this template is available at https://d1-template.templates.workers.dev

Setup Steps

  1. Install the project dependencies with a package manager of your choice:
    npm install
  2. Create a D1 database with the name "d1-template-database":
    npx wrangler d1 create d1-template-database
    ...and update the database_id field in wrangler.json with the new database ID.
  3. Run the following db migration to initialize the database (notice the migrations directory in this project):
    npx wrangler d1 migrations apply --remote d1-template-database
  4. Deploy the project!
    npx wrangler deploy

About

CDN code for zaneops

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •