authentication-using-d1-example
authentication-using-d1-example copied to clipboard
Implementing Register and Login in Cloudflare Workers using D1
Example code for implementing Register and Login in Cloudflare Workers using D1
This is the example code for the article Implementing Register and Login in Cloudflare Workers with D1
that you can read here.
Getting started with this project
Install the dependencies
npm install
Create a new D1 database
wrangler d1 create <db-name> --experimental-backend
Copy the database_id and place it in the wrangler.toml file
[[d1_databases]]
binding = "DB"
database_name = "<your-db-name>"
database_id = "<your-db-id>"
Apply initial migrations, that include the users and users_sessions tables
# Remote development
wrangler d1 migrations apply DB
# Local development
wrangler d1 migrations apply DB --local
Start the project
npm run serve
Images
Swagger interface

Unauthenticated

Authentication

Endpoint results
