fireproof-storage / fireproof

Realtime database, runs anywhere. Install Fireproof in your front-end app or edge function, and sync data via any backend.
https://fireproof.storage
Other
219 stars 16 forks source link

partykit storage #45

Closed jchris closed 6 months ago

jchris commented 6 months ago

Currently the partykit connector is metadata only, but it could handle storage easily. This would simplify development b/c you can deploy partykit only apps, instead of needing s3 or netlify in addition.

jchris commented 6 months ago

make a message format to send to partykit https://github.com/fireproof-storage/fireproof/blob/main/packages/connect-partykit/src/connect-partykit.ts#L74

jchris commented 6 months ago

probably like

    const partyMessage = {
      data: base64String,
      car: carFile.cid.toString(),
    }
jchris commented 6 months ago

we could do something like this and pass cars in realtime, but we also need a rest loader. https://github.com/fireproof-storage/fireproof/blob/a4321d1a14c8899cd3c47ce822071224957d44d6/packages/fireproof/src/loader.ts#L305

const remoteCar = await remote.load(cid)
              if (remoteCar) {
                // todo test for this
                await local.save(remoteCar)
jchris commented 6 months ago

if you start with the rest loader it will just work, and we can do the message delivery someday/never

jchris commented 6 months ago

the rest support probably looks like adding http to server.ts https://docs.partykit.io/guides/responding-to-http-requests/

jchris commented 6 months ago

in that case we might not need to do anything like

partyMessage = {
      data: base64String,
      car: carFile.cid.toString(),
    }

instead we can just PUT and GET from the rest endpoint. Let's do that, it's simpler and more cacheable.

That's how Netlify data store works: https://github.com/fireproof-storage/fireproof/blob/main/packages/connect-netlify/src/server.ts

jchris commented 6 months ago

thank you! I'll add more as I think of it

jchris commented 6 months ago

was merged in https://github.com/fireproof-storage/fireproof/pull/50 thanks @valorant-dhruv