8000 Add adapters for Cloudflare D1 (binding & http) by taivo · Pull Request #717 · remult/remult · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add adapters for Cloudflare D1 (binding & http) #717

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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

taivo
8000 Copy link
@taivo taivo commented Jun 4, 2025

Adapters for Cloudflare D1. Includes createD1DataProvider and createD1HttpDataProvider to demonstrate usage.

There is also a few minor type fixes and dependency updates to get npm run build to work (this is independent of the D1 additions).

8000 Copy link
codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 62.33766% with 29 lines in your changes missing coverage. Please review.

Project coverage is 86.85%. Comparing base (4ab2e60) to head (115d695).

Files with missing lines Patch % Lines
projects/core/remult-d1-http.ts 0.00% 20 Missing ⚠️
projects/core/remult-d1.ts 83.92% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #717      +/-   ##
==========================================
+ Coverage   86.80%   86.85%   +0.04%     
==========================================
  Files         100      102       +2     
  Lines       15991    16306     +315     
  Branches     3816     3831      +15     
==========================================
+ Hits        13881    14162     +281     
- Misses       2110     2144      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jycouet
Copy link
Collaborator
jycouet commented Jun 4, 2025

Started my demo here: nerdfolio#1

@jycouet jycouet mentioned this pull request Jun 5, 2025
3 tasks
@jycouet jycouet marked this pull request as draft June 10, 2025 06:17
@taivo
Copy link
Author
taivo commented Jun 13, 2025

I added tests for d1 using wrangler getPlatformProxy, removed h3 as peer dev, and made some minor fixes to make typescript happy for the npm run build-tests script.

Are we merge-ready?

Copy link
Collaborator
@jycouet jycouet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising.

Do we need worker-configuration.d.ts in source code ? Or it's generated at some point and we could git ignore it ?

Would be nice to add the doc for d1 & d1-http (One page or One each, I don't know), similar to: https://github.com/remult/remult/edit/main/docs/docs/installation/database/duckdb.md

Thank you for all this & running tests 🎉

Copy link
8000
Collaborator
@jycouet jycouet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand remult-d1-http is not providing much, no ?
Or you have to have it with remult-d1 ? I mean, you will use one or the other or both ?
I'm not sure what test to add to this http binding.


Just to be sure, you are using this in your project (userland), so there is no timing pressure to have this in remult core, right ? We will make it, just, I would like to do it properly ;)

Thank you very much for your contributions 🎉

@taivo
Copy link
Author
taivo commented Jun 21, 2025

It would be nice to have this merged into remult so I don't have to maintain a local version. Chances are it will be only me that's using it for next next few weeks to workout kinks if any. Easier to do that if the code is merged imo, but your call.

As for d1-http, testing would be similar to Turso in the sense that you'd have to setup cloudflare credentials and an actual project with apiKey and databaseId to use. The d1-http use case is not really meant for production but for occasional viewing of the production db (via remult-admin perhaps) or one-off scripts that's inititated from the local computer (or anywhere outside of cloudflare platform). It's useful but it's mostly meant to be a dev tool. remult-d1 is the main production driver.

@jycouet
Copy link
Collaborator
jycouet commented Jun 25, 2025

It would be nice to have this merged into remult so I don't have to maintain a local version. Chances are it will be only me that's using it for next next few weeks to workout kinks if any. Easier to do that if the code is merged imo, but your call.

As for d1-http, testing would be similar to Turso in the sense that you'd have to setup cloudflare credentials and an actual project with apiKey and databaseId to use. The d1-http use case is not really meant for production but for occasional viewing of the production db (via remult-admin perhaps) or one-off scripts that's inititated from the local computer (or anywhere outside of cloudflare platform). It's useful but it's mostly meant to be a dev tool. remult-d1 is the main production driver.

Hey Tai 👋,

We are not that comfortable in publishing d1-http like this, without tests but part of the public remult API.
May you remove d1-http for the PR and start with d1 first ?
I'll update doc (& landing) with d1 as soon as we merge this one.

Thanks a lot.


Side question, your code is also on Cloudflare ? Or just d1 ?

@noam-honig
Copy link
Collaborator

@taivo alternatively - if you have working tests for http that require a cloud account for it. you can store that account in an environment variable - and run the tests on your machine before you push.

Later we'll add an environment variable on the CI to run these tests there - but I want to make sure that its covered and tested before we add this to the root of our public api

@taivo
Copy link
Author
taivo commented Jun 27, 2025

No problem, guys. Give me a few days. I'll set up d1-http tests. Keep up the good work!

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.

3 participants
0