Deno doc

Deco (deh · kow) is a helper library for Deno developers (still work in progress)

  • Fault tolerance helpers (@Timeout, @Retry, @Try, @Trace, @Debounce, @Throttle, @RateLimit, @Concurrecy, @Memoize)
  • REST API helpers (@Http.xxx) with OpenAPI support
  • Dapr helpers (@Dapr.xxx)

Dapr example

const { TELEGRAM_CHATID, TELEGRAM_TOKEN } = await Secrets.getAll(
  "example-secrets-store",
);
const PUBSUBNAME = "pubsub";

class DaprApp {
  @PubSub.subscribe({ pubSubName: PUBSUBNAME, topic: "A" })
  topicA({ data }: { data: unknown }) {
    console.log("topicA =>", data);
  }

  @PubSub.subscribe({ pubSubName: PUBSUBNAME, topic: "B" })
  topicB({ data }: { data: Record<string, unknown> }) {
    console.log("topicB =>", data);
    if (data.text && TELEGRAM_CHATID && TELEGRAM_TOKEN) {
      const { text } = data;
      const path =
        `/bot${TELEGRAM_TOKEN}/sendMessage?chat_id=${TELEGRAM_CHATID}&text=${text}`;
      Bindings.invoke({
        name: "telegram",
        operation: "get",
        metadata: { path },
      });
    }
  }

  @PubSub.subscribe({
    pubSubName: PUBSUBNAME,
    topic: "C",
    metadata: { rawPayload: "true" },
  })
  topicC(raw: Record<string, unknown>) {
    console.log("topicC =>", raw);
  }

  @Bindings.listenTo("tweets")
  tweets({ text }: { text: Record<string, unknown> }) {
    PubSub.publish({
      data: { text },
      pubSubName: PUBSUBNAME,
      topic: "A",
    });
  }
}

console.log("Dapr app started...");
Dapr.start({ appPort: 3000, controllers: [DaprApp] });

Running tests

deno test --allow-net

Http server performance (~19k RPS)

Http server benchmark