kwhitley / itty-durable

Cloudflare Durable Objects + Itty Router = shorter code
MIT License
244 stars 18 forks source link

Expose storage in state property #27

Open maurerbot opened 1 year ago

maurerbot commented 1 year ago

I would be nice to access the this.state.storage object in the proxy object.

Why?

I've migrated to itty-durable from a standard DO. Itty-durable property proxy stores everything in a data property so I can t access my existing data properties. The storage object is there but is not exposed via types so I have to ignore the type checker and do a run time migration.

Proposal

A) If storage is not meant to be exposed don't store everything in a single data object. Or B) expose storage by typing state argument with DurableObjectState https://github.com/kwhitley/itty-durable/blob/v1.x/src/itty-durable.js#L20

aarhus commented 1 year ago

I have created a PR for this

26

If you look at my gists, I have extended the base class to support this and to use do-taskmanager

maurerbot commented 1 year ago

I have created a PR for this #26

If you look at my gists, I have extended the base class to support this and to use do-taskmanager

awesome, can you link the gist?

aarhus commented 1 year ago

Sorry, hadn't realised that it wasn't public

https://gist.github.com/aarhus/d7d6d7e1778367994f9e33c37a08074e