-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat(server): Add Server Context Support #621
Conversation
2699557
to
6745cc7
Compare
By the way, I can also work on documenting this if you'd like. This is a super minimal implementation that I came up with in about an hour to allow me to use D1 in a bot of mine. |
I like the implementation, I'd also like to extend this implementation towards the other contexts, you'd probably be better to extend from Another thing I'd like to do as a whole cloudflare worker focused update is to automatically get the variables for the discord app ID, token, and public key while responding to a request, since the |
Co-authored-by: Snazzah <[email protected]>
This does look better! I'll keep playing to see if I can find a way to make type inference work better in a subsequent PR |
Cool, the only thing to do now is to put server contexts in |
This is a straightforward solution to #620, implementing a
CommandContext.serverContext
property that can be defined by the Server.CommandContext.serverContext
is naturally a generic of the default typeunknown
, leaving the user responsible for determining its type and handling casts accordingly. This fits with the use case of CloudFlare Workers, as its structure changes depending on how bindings are defined.Consequently, this PR enables using Durable Objects and D1 databases in bots. Through the use of Durable Objects, many things that could only previously be achieved in stateful workflows can now be achieved in serverless.