Unverified Commit 133bc111 authored by Hong Minhee's avatar Hong Minhee
Browse files

Add AMQP support to `fedify init`

parent b7b27a10
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -39,6 +39,11 @@ To be released.
     -  `new Service()` constructor now accepts `followedMessage` option.
     -  `Service.clone()` method now accepts `followedMessage` option.

 -  Add options for an AMQP driver to `fedify init` command.

     -  Added `amqp` value to the `-q`/`--message-queue` option of
        the `fedify init` command.

 -  Added more log messages using the [LogTape] library.  Currently the below
    logger categories are used:

+27 −1
Original line number Diff line number Diff line
@@ -437,6 +437,7 @@ interface KvStoreDescription {
  label: string;
  runtimes?: Runtime[];
  dependencies?: Record<string, string>;
  devDependencies?: Record<string, string>;
  imports?: Record<string, string | string[]>;
  object: string | Record<Runtime, string>;
  denoUnstable?: string[];
@@ -485,12 +486,13 @@ const kvStores: Record<KvStore, KvStoreDescription> = {
  },
} as const;

type MessageQueue = "redis" | "postgres" | "denokv";
type MessageQueue = "redis" | "postgres" | "amqp" | "denokv";

interface MessageQueueDescription {
  label: string;
  runtimes?: Runtime[];
  dependencies?: Record<string, string>;
  devDependencies?: Record<string, string>;
  imports?: Record<string, string | string[]>;
  object: string | Record<Runtime, string>;
  denoUnstable?: string[];
@@ -533,6 +535,28 @@ const messageQueues: Record<MessageQueue, MessageQueueDescription> = {
      DATABASE_URL: "postgres://postgres@localhost:5432/postgres",
    },
  },
  amqp: {
    label: "AMQP (e.g., RabbitMQ)",
    dependencies: {
      "@fedify/amqp": "^0.1.0",
      "npm:amqplib": "^0.10.4",
    },
    devDependencies: {
      "npm:@types/amqplib": "^0.10.5",
    },
    imports: {
      "@fedify/amqp": ["AmqpMessageQueue"],
      amqplib: ["connect"],
    },
    object: {
      deno: 'new AmqpMessageQueue(await connect(Deno.env.get("AMQP_URL")))',
      node: "new AmqpMessageQueue(await connect(process.env.AMQP_URL))",
      bun: "new AmqpMessageQueue(await connect(process.env.AMQP_URL))",
    },
    env: {
      AMQP_URL: "amqp://localhost",
    },
  },
  denokv: {
    label: "Deno KV",
    runtimes: ["deno"],
@@ -1022,6 +1046,8 @@ await configure({
      const devDependencies: Record<string, string> = {
        "@biomejs/biome": "^1.8.3",
        ...initializer.devDependencies,
        ...kvStoreDesc?.devDependencies,
        ...mqDesc?.devDependencies,
      };
      await addDependencies(
        runtime,
+5 −1
Original line number Diff line number Diff line
@@ -97,7 +97,8 @@ project. It will ask you a few questions to set up the project:
 -  Web framework: Bare-bones, [Fresh] (if Deno), [Hono], [Express] (unless
    Deno), or [Nitro] (unless Deno)
 -  Key-value store: In-memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno)
 -  Message queue: In-memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno)
 -  Message queue: In-memory, [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]),
    or [Deno KV] (if Deno)

Alternatively, you can specify the options in the command line to skip some of
interactive prompts:
@@ -111,6 +112,8 @@ interactive prompts:
[Nitro]: https://nitro.unjs.io/
[Redis]: https://redis.io/
[PostgreSQL]: https://www.postgresql.org/
[AMQP]: https://www.amqp.org/
[RabbitMQ]: https://www.rabbitmq.com/
[Deno KV]: https://deno.com/kv

### `-r`/`--runtime`: JavaScript runtime
@@ -165,6 +168,7 @@ option. The available options are:

 -  `redis`: [Redis]
 -  `postgres`: [PostgreSQL]
 -  `amqp`: [AMQP] (e.g., [RabbitMQ])
 -  `denokv`: [Deno KV] (if Deno)

If it's omitted, the in-process message queue (which is for development purpose)
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ Select *Node.js*, *npm*, *Hono*, *In-memory*, and *In-process* in order:
❯ In-process
  Redis
  PostgreSQL
  AMQP (e.g., RabbitMQ)
  Deno KV
~~~~