//my script ```import { Miniflare } from 'miniflar...
# durable-objects
c
//my script
Copy code
import { Miniflare } from 'miniflare';

const mf = new Miniflare({
    modules: true,
    durableObjects: { TEST_OBJECT: 'TestObject' },
    script: `
   export class TestObject {
     constructor(state) {
       this.storage = state.storage;
     }
 
     async fetch(request) {
       const url = new URL(request.url);
       if(url.pathname === "/put") await this.storage.put("key", 1);
       return new Response((await this.storage.get("key")).toString());
     }
   }

   export default {
      async fetch(request, env) {
        const stub = env.TEST_OBJECT.get(env.TEST_OBJECT.idFromName("test"));
        return stub.fetch(request);
      }
    }
   `
});

let res = await mf.dispatchFetch('http://localhost:8787/put');
console.log(await res.text()); // "1"