Skip to content
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

[queues] correct DurableObject to DurableObjectNamespace & remove constructor block #14529

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions content/queues/examples/use-queues-with-durable-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ filename: src/index.ts
---
interface Env {
YOUR_QUEUE: Queue;
YOUR_DO_CLASS: DurableObject;
YOUR_DO_CLASS: DurableObjectNamespace;
}

export default {
Expand All @@ -74,17 +74,12 @@ export default {
// This would return "wrote to queue", but you could return any response.
return response;
}
return new Response("userId must be provided", { status: 400 });
}
}

export class YourDurableObject implements DurableObject {
constructor(public state: DurableObjectState, env: Env) {
this.state = state;
// Ensure you pass your bindings and environment variables into
// each Durable Object when it is initialized
this.env = env;
}
}
constructor(private state: DurableObjectState, private env: Env) {}

async fetch(request: Request) {
// Error handling elided for brevity.
Expand Down
Loading