Internals

Actor Runtime

The actor runtime requires that user scripts contain a default export with an async function called start:

export default {
  async start(ctx: ActorContext) {
    // ...
  }
};
index.js

This can also be a class with a static method:

export default class MyClass {
  static async start(ctx: ActorContext) {
    // ...
  }
}
index.js

The runtime provides a single argument with type ActorContext:

interface ActorContext {
  metadata: {
    actor: {
      id: string;
      tags: Record<string, string>;
      createdAt: Date;
    };
    project: {
      id: string;
      slug: string;
    };
    environment: {
      id: string;
      slug: string;
    };
    cluster: {
      id: string;
    };
    region: {
      id: string;
      name: string;
    };
    build: {
      id: string;
    };
  };
  kv: {
    // ...See docs for state... †
  };
}
TypeScript

† state