File
Blob: src/worker/common/stub.ts
| 1 | import type { RepoDurableObject } from "@/worker/do"; |
| 2 | /** |
| 3 | * Get the Durable Object stub for a repository. |
| 4 | * @param env - Cloudflare environment bindings |
| 5 | * @param repoId - RepoDO storage identity (`doName` in D1) |
| 6 | * @returns DurableObjectStub for the specified repository |
| 7 | */ |
| 8 | export function getRepoStub(env: Env, repoId: string): DurableObjectStub<RepoDurableObject> { |
| 9 | const id = env.REPO_DO.idFromName(repoId); |
| 10 | return env.REPO_DO.get(id); |
| 11 | } |
| 12 | |
| 13 | export function getRepoStubByDoId(env: Env, doId: string): DurableObjectStub<RepoDurableObject> { |
| 14 | const id = env.REPO_DO.idFromString(doId); |
| 15 | return env.REPO_DO.get(id); |
| 16 | } |