Skip to content

Commit 8bbfb51

Browse files
authored
Merge pull request #638 from 2chanhaeng/init
Revive removed `fedify init` options
2 parents 7b8990b + 731f3e3 commit 8bbfb51

12 files changed

Lines changed: 192 additions & 11 deletions

File tree

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ Released on March 19, 2026.
2222
repository-relative path logic has been made safe for published JSR
2323
execution. [[#624], [#633]]
2424

25+
- Revived removed `fedify init` options. [[#632], [#638] by ChanHaeng Lee]
26+
- `bare-bones` option for web framework.
27+
- `in-memory` option for key-value store.
28+
- `in-process` option for message queue.
29+
2530
[#624]: https://github.com/fedify-dev/fedify/issues/624
31+
[#632]: https://github.com/fedify-dev/fedify/issues/632
2632
[#633]: https://github.com/fedify-dev/fedify/pull/633
33+
[#638]: https://github.com/fedify-dev/fedify/pull/638
2734

2835
### @fedify/vocab-runtime
2936

docs/cli.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: >-
55
features of the fedify command.
66
---
77

8+
<!-- deno-fmt-ignore-file -->
9+
810
`fedify`: CLI toolchain
911
=======================
1012

@@ -222,11 +224,12 @@ fedify init my-fedify-project
222224
The above command will start the interactive prompt to initialize a new Fedify
223225
project. It will ask you a few questions to set up the project:
224226

225-
- Web framework: [Hono], [Elysia], [Express], [Nitro], or [Next.js]
227+
- Web framework: Bare-bones, [Hono], [Elysia], [Express], [Nitro],
228+
or [Next.js]
226229
- Package manager: [Deno], [Bun], [npm], [pnpm], or [Yarn]
227-
- Message queue: [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]),
230+
- Message queue: In-Process, [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]),
228231
or [Deno KV] (if Deno)
229-
- Key–value store: [Redis], [PostgreSQL], or [Deno KV] (if Deno)
232+
- Key–value store: In-Memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno)
230233

231234
> [!TIP]
232235
> Projects created with `fedify init` automatically include [`@fedify/lint`]
@@ -276,6 +279,8 @@ option. The available options are:
276279
You can specify the web framework to integrate with Fedify by using
277280
the `-w`/`--web-framework` option. The available options are:
278281

282+
- `bare-bones`: A minimal setup without any web framework integration, but in
283+
Node.js, [Hono] is used for a simple adapter for a lightweight experience.
279284
- `hono`: [Hono]
280285
- `nitro`: [Nitro]
281286
- `next`: [Next.js]
@@ -287,6 +292,8 @@ the `-w`/`--web-framework` option. The available options are:
287292
You can specify the key–value store to use by using the `-k`/`--kv-store`
288293
option. The available options are:
289294

295+
- `in-memory`: An in-memory key–value store that does not persist data across
296+
restarts. This is useful for testing and development purposes.
290297
- `redis`: [Redis]
291298
- `postgres`: [PostgreSQL]
292299
- `denokv`: [Deno KV] (if Deno)
@@ -296,6 +303,8 @@ option. The available options are:
296303
You can specify the message queue to use by using the `-m`/`--message-queue`
297304
option. The available options are:
298305

306+
- `in-process`: An in-process message queue that does not persist messages
307+
across restarts. This is useful for testing and development purposes.
299308
- `redis`: [Redis]
300309
- `postgres`: [PostgreSQL]
301310
- `amqp`: [AMQP] (e.g., [RabbitMQ])

packages/init/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Supported options
2525

2626
The initializer supports the following project configurations:
2727

28-
- **Web frameworks**: [Hono], [Nitro], [Next.js], [Elysia], [Express]
28+
- **Web frameworks**: Bare-bones, [Hono], [Nitro], [Next.js], [Elysia], [Express]
2929
- **Package managers**: Deno, pnpm, Bun, Yarn, npm
30-
- **Key-value stores**: Deno KV, Redis, PostgreSQL
31-
- **Message queues**: Deno KV, Redis, PostgreSQL, AMQP
30+
- **Key-value stores**: In-Memory, Deno KV, Redis, PostgreSQL
31+
- **Message queues**: In-Process, Deno KV, Redis, PostgreSQL, AMQP
3232

3333
[Hono]: https://hono.dev/
3434
[Nitro]: https://nitro.build/

packages/init/src/const.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
import kv from "./json/kv.json" with { type: "json" };
2+
import mq from "./json/mq.json" with { type: "json" };
3+
4+
/** All supported package manager identifiers, in display order. */
15
export const PACKAGE_MANAGER = ["deno", "pnpm", "bun", "yarn", "npm"] as const;
26
export const WEB_FRAMEWORK = [
7+
"bare-bones",
38
"hono",
49
"nitro",
510
"next",
611
"elysia",
712
"express",
813
] as const;
9-
export const MESSAGE_QUEUE = ["denokv", "redis", "postgres", "amqp"] as const;
10-
export const KV_STORE = ["denokv", "redis", "postgres"] as const;
14+
15+
/** All supported message queue backend identifiers. */
16+
export const MESSAGE_QUEUE = Object.keys(mq) as readonly (keyof typeof mq)[];
17+
18+
/** All supported key-value store backend identifiers. */
19+
export const KV_STORE = Object.keys(kv) as readonly (keyof typeof kv)[];
20+
1121
export const DB_TO_CHECK = ["redis", "postgres", "amqp"] as const;

packages/init/src/json/kv.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
2+
"in-memory": {
3+
"label": "In-Memory",
4+
"packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],
5+
"imports": {
6+
"@fedify/fedify": { "MemoryKvStore": "MemoryKvStore" }
7+
},
8+
"object": "new MemoryKvStore()"
9+
},
210
"redis": {
311
"label": "Redis",
412
"packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],

packages/init/src/json/mq.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"in-process": {
3+
"label": "In-Process",
4+
"packageManagers": [
5+
"deno",
6+
"bun",
7+
"npm",
8+
"yarn",
9+
"pnpm"
10+
],
11+
"imports": {
12+
"@fedify/fedify": {
13+
"InProcessMessageQueue": "InProcessMessageQueue"
14+
}
15+
},
16+
"object": "new InProcessMessageQueue()"
17+
},
218
"redis": {
319
"label": "Redis",
420
"packageManagers": [

packages/init/src/lib.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ const addFedifyDeps = <T extends object>(json: T): T =>
3939
key,
4040
toMerged(value, {
4141
dependencies: {
42-
[`@fedify/${key}`]: PACKAGE_VERSION,
42+
...(NO_INTEGRATIONS.includes(key) ? {} : {
43+
[`@fedify/${key}`]: PACKAGE_VERSION,
44+
}),
4345
},
4446
}),
4547
]),
4648
) as T;
49+
const NO_INTEGRATIONS = ["in-memory", "in-process", "bare-bones"];
50+
4751
export const kvStores = addFedifyDeps(kv as KvStores);
4852
export const messageQueues = addFedifyDeps(mq as MessageQueues);
4953
const toRegExp = (str: string): RegExp => new RegExp(str);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { behindProxy } from "x-forwarded-fetch";
2+
import federation from "./federation.ts";
3+
import "./logging.ts";
4+
5+
const server = Bun.serve({
6+
port: 8000,
7+
fetch: behindProxy((req) =>
8+
new URL(req.url).pathname === "/"
9+
? new Response("Hello, this is a Fedify server!", {
10+
headers: { "Content-Type": "text/plain" },
11+
})
12+
: federation.fetch(req, { contextData: undefined })
13+
),
14+
});
15+
16+
console.log("Server started at", server.url.href);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import "@std/dotenv/load";
2+
import { behindProxy } from "@hongminhee/x-forwarded-fetch";
3+
import federation from "./federation.ts";
4+
import "./logging.ts";
5+
6+
Deno.serve(
7+
{
8+
port: 8000,
9+
onListen: ({ port, hostname }) =>
10+
console.log("Server started at http://" + hostname + ":" + port)
11+
},
12+
behindProxy((req) =>
13+
new URL(req.url).pathname === "/"
14+
? new Response("Hello, this is a Fedify server!", {
15+
headers: { "Content-Type": "text/plain" },
16+
})
17+
: federation.fetch(req, { contextData: undefined })
18+
),
19+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { serve } from "@hono/node-server";
2+
import { behindProxy } from "x-forwarded-fetch";
3+
import federation from "./federation.ts";
4+
import "./logging.ts";
5+
6+
serve(
7+
{
8+
port: 8000,
9+
fetch: behindProxy((req) =>
10+
new URL(req.url).pathname === "/"
11+
? new Response("Hello, this is a Fedify server!", {
12+
headers: { "Content-Type": "text/plain" },
13+
})
14+
: federation.fetch(req, { contextData: undefined })
15+
),
16+
},
17+
(info) =>
18+
console.log("Server started at http://" + info.address + ":" + info.port)
19+
);

0 commit comments

Comments
 (0)