| 49 | // on the same door by id. The options callback runs after super(...), |
| 50 | // so it can read self.ctx / self.env. |
| 51 | export class ContainerExample extends withWorkspace(class extends DurableObject<Env> {}, (self) => { |
| 52 | const { ctx, env } = self as unknown as { ctx: DurableObjectState; env: Env }; |
| 53 | return { |
| 54 | // ctx.storage.sql.exec returns a narrower row type than |
| 55 | // DurableObjectStorageLike declares; the runtime shape |
| 56 | // matches. Cast through unknown to bypass invariance. |
| 57 | storage: ctx.storage as unknown as DurableObjectStorageLike, |
| 58 | backends: [ |
| 59 | new WorkerShellBackend({ |
| 60 | loader: env.LOADER, |
| 61 | workspace: { binding: "ContainerExample", id: ctx.id.toString() }, |
| 62 | ctx, |
| 63 | }), |
| 64 | ], |
| 65 | // Mount the Bucket binding at /workspace/r2. Seed it with |
| 66 | // `npm run seed:r2` so the first read returns "hello world". |
| 67 | // The bucket is read-only; writes under /workspace/r2 |
| 68 | // reject with EROFS. |
| 69 | mounts: { |
| 70 | "/workspace/r2": R2Bucket(env.Bucket), |
| 71 | }, |
| 72 | }; |
| 73 | }) {} |
| 74 | |
| 75 | // --------------------------------------------------------------- |
| 76 | // Worker HTTP surface (mirrors examples/container) |
nothing calls this directly
no test coverage detected