Git Product home page Git Product logo

Comments (3)

evanderkoogh avatar evanderkoogh commented on August 19, 2024

Can you give a code example that doesn't work @mikecann? I just tried it and it seems to work just fine?

const id = ns.newUniqueId()
const stub = ns.get(id)
console.log(stub.id.toString())

from miniflare.

mikecann avatar mikecann commented on August 19, 2024
import { router } from "./routes";

export { UserAggregate } from "./aggregates/user/UserAggregate";

export interface EnvInterface {
  UserAggregate: DurableObjectNamespace;
}

export default {
  async fetch(request: Request, env: EnvInterface): Promise<Response> {
    console.log(`TEST`, env.UserAggregate.newUniqueId());
    return new Response(`done`);
  },
};

Outputs: TEST DurableObjectId { name: undefined }

I am using esbuild to bundle my worker:

import { build } from "esbuild";

const isWatchMode = () => false;
const config = {};

async function bootstrap() {
  console.log(`starting`, config);

  await build({
    entryPoints: ["./src/index.ts"],
    bundle: true,
    format: "esm",
    outdir: `dist`,
    outExtension: { ".js": ".mjs" },
    sourcemap: "external",
    platform: "node",
    target: [`node14`],
    external: [],
    watch: isWatchMode()
      ? {
          onRebuild(err, result) {
            if (err) console.error("watch build failed:", err);
            else console.log("watch build succeeded");
          },
        }
      : undefined,
    // banner: {
    //   js: constructServerBannerEnvInjection(getBTEnvVarsForBannerInjection()),
    // },
  });

  console.log(`build complete`);
}

bootstrap()
  .then(() => {
    if (!isWatchMode()) {
      console.log(`build done, exiting now.`);
      process.exit(0);
    }
  })
  .catch(e => {
    console.error(e);
    process.exit(1);
  });

from miniflare.

mikecann avatar mikecann commented on August 19, 2024

scratch that sorry if I do toString() on the ID I get 000000017b4cc362ba6844a4e72bc0cffedebbdcbc9fbd16762ae91aa9b85edb. Apologies for the confusion!

from miniflare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.