Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update template to use D1 #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update template to use D1 #3

wants to merge 1 commit into from

Conversation

triozer
Copy link
Member

@triozer triozer commented Jan 7, 2025

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):

  • Replaced Cloudflare KV storage with D1 database for improved query capabilities and better data management
  • Added schema.sql with new key_values table to store OAuth-related data

Refactoring OAuth Flow:

  • src/index.ts: Refactored the OAuth flow by delegating the authorization, redirection, polling, and token refreshing logic to the new provider 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, and vitest. This ensures compatibility with the latest features and security patches.

Enhancing HTML Template:

  • src/getHTMLTemplate.ts: Enhanced the getHTMLTemplate function to accept title and message parameters and updated the HTML structure and styles for better user experience.

Configuration and Documentation Updates:

  • .dev.vars.example: Moved the PLUGIN_ID variable to a more appropriate location in the file.
  • README.md: Added instructions for installing mkcert, creating development certificates, and seeding the local database to improve the setup process for local development.

Database Schema:

  • src/schema.sql: Added a new table key_values to store key-value pairs, which supports the new OAuth flow implementation.

QA

  • Follow the README
  • To run against this branch use: npm create cloudflare@latest -- --template framer/plugin-oauth#feature/use-d1

@triozer triozer force-pushed the feature/use-d1 branch 2 times, most recently from f81d41a to 082a058 Compare January 7, 2025 15:56
@triozer triozer requested a review from huntercaron January 7, 2025 15:57
- Add bootstrap command

Signed-off-by: Cédric Boirard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant