deepkit-framework
deepkit-framework copied to clipboard
feat(cloudflare): cloudflare workers support for http & rpc packages
Summary of changes
Initial implementation of Cloudflare Workers support for HTTP & RPC.
TODO
- [ ] Auth
Blockers
- [ ] https://github.com/deepkit/deepkit-framework/issues/236
- [ ]
new Functionis not allowed for security reasons
Relinquishment of Rights
Please mark following checkbox to confirm that you relinquish all rights of your changes:
- [x] I waive and relinquish all rights regarding this changes (including code, text, and images) to Deepkit UG (limited), Germany. This changes (including code, text, and images) are under MIT license without name attribution, copyright notice, and permission notice requirement.
Note: we found out Cloudfare doesn't support new Function and thus does not support Deepkit.
maybe providing an option to opt-out of jit?
maybe providing an option to opt-out of jit?
Too much effort for too little reward.
It'd be better to ask Cloudflare to provide an option that'll enable support for new Function.
Unlikely. Edge runtime takes security so seriously that they ban dynamic codes 😅
I definitely do not rewrite the core of Deepkit's libraries just to support one platforms's "security" decision (which is no security related decision).
Not an expert on cloudflare, but as a workaround it should be easy to write a new file (with the validation function) and import that dynamically. it's basically the same as using new Function();
ps: also this way an AOT could be implemented
@CristianPi it could be interesting. I think if we can get DI running the rest would be easy.
Note: we found out Cloudfare doesn't support
new Functionand thus does not support Deepkit.
From what I search the codebase using: https://github.com/search?q=%22new+Function%28%22+repo%3Adeepkit%2Fdeepkit-framework&type=Code&ref=advsearch&l=&l=
Only bson seems to be an issue when running inside Cloudflare, the compiler package I assume is only used during compilation.
@marcj did I miss something?
From what I understand JIT (new Function) is instrumental to almost everything :)
This is because "compilation" actually happens at runtime.
From what I understand JIT (
new Function) is instrumental to almost everything :)
Yeah, Deepkit creates dynamically optimized JIT functions under the hood.
very interested in this if it were to work.
Not an expert on cloudflare, but as a workaround it should be easy to write a new file (with the validation function) and import that dynamically. it's basically the same as using new Function();
ps: also this way an AOT could be implemented
Does cf worker ever provides a file system?
No