Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
See https://github.com/framer/company/issues/31205.
What was done
This pull request introduces several significant changes, focusing on migrating from Cloudflare KV to D1 database, refactoring the OAuth flow, updating dependencies, and enhancing the HTML template.
Database Migration (KV to D1):
Refactoring OAuth Flow:
src/index.ts
: Refactored the OAuth flow by delegating the authorization, redirection, polling, and token refreshing logic to the newprovider
module. This modularization simplifies the main request handler.src/provider.ts
: Added new functions (authorize
,redirect
,poll
,refresh
) to handle different parts of the OAuth flow, improving code organization and readability.Updating Dependencies:
package.json
: Updated several dependencies to their latest versions, including@cloudflare/vitest-pool-workers
,@cloudflare/workers-types
,typescript
, andvitest
. This ensures compatibility with the latest features and security patches.Enhancing HTML Template:
src/getHTMLTemplate.ts
: Enhanced thegetHTMLTemplate
function to accepttitle
andmessage
parameters and updated the HTML structure and styles for better user experience.Configuration and Documentation Updates:
.dev.vars.example
: Moved thePLUGIN_ID
variable to a more appropriate location in the file.README.md
: Added instructions for installingmkcert
, creating development certificates, and seeding the local database to improve the setup process for local development.Database Schema:
src/schema.sql
: Added a new tablekey_values
to store key-value pairs, which supports the new OAuth flow implementation.QA
npm create cloudflare@latest -- --template framer/plugin-oauth#feature/use-d1