DO + pages

You need a second Worker, also running dev
12 Replies
aroman
aroman15mo ago
You mean like multiple wrangler dev calls?
Hello, I’m Allie!
Yup
aroman
aroman15mo ago
i see! so my repo directory structure should be like:
package.json
src/
public/
durable_objects/
—— package.json
—— wrangler.toml
—— src/
package.json
src/
public/
durable_objects/
—— package.json
—— wrangler.toml
—— src/
essentially a module (with package.json + wrangler.toml inside a subdirectory of my Pages repo) ah, figured it out!
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
aroman
aroman15mo ago
yep! i was able to get a worker in the pages deploy to bind to a durable object, both locally and remotely
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
aroman
aroman15mo ago
haha, that's what i did too, using the discord search function scoped to the #durable-objects channel 🙂 I think this is demonstrable proof that DO and DO+Pages needs better documentation...
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
Hello, I’m Allie!
Yes, and no, not necessarily Basically, the Worker is only needed to publish the DO class. It doesn't need any of the normal Worker logic. It could be as simple as
export class SomeDOClass {
// ...
}
export class SomeDOClass {
// ...
}
Notice the lack of export default This also means that you can bind directly to the DO from your Functions, and not have to invoke the Worker itself at all
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
Hello, I’m Allie!
What if you do
name = "langchain-storage"
compatibility_date = "2023-05-04"
main = "./src/index.ts"
no_bundle = true

[durable_objects]
bindings = [{name = "LANGCHAIN", class_name = "LangChainStorage"}]

[[migrations]]
tag = "v1"
new_classes = ["LangChainStorage"]
name = "langchain-storage"
compatibility_date = "2023-05-04"
main = "./src/index.ts"
no_bundle = true

[durable_objects]
bindings = [{name = "LANGCHAIN", class_name = "LangChainStorage"}]

[[migrations]]
tag = "v1"
new_classes = ["LangChainStorage"]
Oh wait Bundle it first, then change the main Or just add an
export default {}
export default {}
to the file
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View