Skip to content

Carrier

Durable email and Durable Object messaging for TypeScript on Cloudflare, D1 or PostgreSQL, with an honest record of what was actually delivered.

  • @fungi.computer/carrier
  • v0.2.0
  • MIT

Fastest path

  1. Install

    Add it to your project with npm, pnpm, Yarn or Bun.

    TERMINAL
    npm install @fungi.computer/carrier
  2. Send an email and check its status

    Sends one email through an in-memory node:sqlite store and a fake transport, ticks the queued dispatch, then prints the resulting status.

    home.ts
    import { DatabaseSync } from "node:sqlite";
    import { fromNodeSqlite } from "@fungi.computer/watchdog/node-sqlite";
    import { createCarrier } from "@fungi.computer/carrier";
    const carrier = await createCarrier({
    storage: fromNodeSqlite(new DatabaseSync(":memory:")),
    now: Date.now,
    host: { commit: async (mutation) => mutation(), requestWake: async () => {} },
    transport: async () => ({
    kind: "provider_accepted",
    providerMessageId: "demo-1",
    }),
    });
    const receipt = await carrier.send({
    id: "welcome:1",
    from: "hello@example.com",
    to: ["ada@example.net"],
    subject: "Welcome",
    text: "Ready.",
    });
    await carrier.tick();
    console.log((await carrier.get(receipt.id))?.status); // "provider_accepted"