Skip to content

Commit a52c2b8

Browse files
authored
Merge pull request #496 from dodok8/feat/460
Add ElysiaJS option to `fedify init`
2 parents a30e1ef + ca76f5d commit a52c2b8

10 files changed

Lines changed: 190 additions & 8 deletions

File tree

CHANGES.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,20 @@ To be released.
9696
already support this method. [[#499], [#506]]
9797

9898
[#280]: https://github.com/fedify-dev/fedify/issues/280
99+
[#297]: https://github.com/fedify-dev/fedify/issues/297
99100
[#366]: https://github.com/fedify-dev/fedify/issues/366
100101
[#376]: https://github.com/fedify-dev/fedify/issues/376
102+
[#391]: https://github.com/fedify-dev/fedify/pull/391
101103
[#392]: https://github.com/fedify-dev/fedify/pull/392
102104
[#393]: https://github.com/fedify-dev/fedify/pulls/393
103105
[#433]: https://github.com/fedify-dev/fedify/pull/433
104106
[#434]: https://github.com/fedify-dev/fedify/pull/434
105107
[#444]: https://github.com/fedify-dev/fedify/issues/444
106108
[#445]: https://github.com/fedify-dev/fedify/pull/445
107109
[#451]: https://github.com/fedify-dev/fedify/pull/451
108-
[#391]: https://github.com/fedify-dev/fedify/pull/391
109110
[#466]: https://github.com/fedify-dev/fedify/issues/466
110111
[#499]: https://github.com/fedify-dev/fedify/issues/499
112+
[#494]: https://github.com/fedify-dev/fedify/pull/494
111113
[#506]: https://github.com/fedify-dev/fedify/pull/506
112114

113115
### @fedify/cli
@@ -133,6 +135,15 @@ To be released.
133135
`-t`/`--traverse` option, allowing users to traverse multiple collections
134136
in a single command. [[#408], [#449] by Jiwon Kwon]
135137

138+
- The `fedify init` command now supports [Elysia] as a web framework option,
139+
with runtime-specific templates for Deno, Bun, and Node.js environments.
140+
[[#460], [#496] by Hyeonseo Kim]
141+
142+
- Fixed a bug in the `fedify init` command where Deno import map generation
143+
incorrectly handled dependencies with registry prefixes (e.g., `npm:`),
144+
creating invalid specifiers in *deno.json*. [[#460], [#496] by Hyeonseo Kim]
145+
146+
[Elysia]: https://elysiajs.com/
136147
[#374]: https://github.com/fedify-dev/fedify/issues/374
137148
[#397]: https://github.com/fedify-dev/fedify/issues/397
138149
[#408]: https://github.com/fedify-dev/fedify/issues/408
@@ -141,6 +152,8 @@ To be released.
141152
[#456]: https://github.com/fedify-dev/fedify/issues/456
142153
[#457]: https://github.com/fedify-dev/fedify/pull/457
143154
[#458]: https://github.com/fedify-dev/fedify/pull/458
155+
[#460]: https://github.com/fedify-dev/fedify/issues/460
156+
[#496]: https://github.com/fedify-dev/fedify/pull/496
144157

145158
### @fedify/relay
146159

@@ -196,11 +209,19 @@ To be released.
196209
- This package is primarily used by generated vocabulary classes and
197210
provides the runtime infrastructure for ActivityPub object processing.
198211

212+
### @fedify/elysia
213+
214+
- Added *deno.json* configuration file to enable proper Deno tooling support
215+
in the package. [[#460], [#496]]
216+
217+
[#460]: https://github.com/fedify-dev/fedify/issues/460
218+
[#496]: https://github.com/fedify-dev/fedify/pull/496
219+
199220
### @fedify/lint
200221

201222
- Created Fedify linting tools as the *@fedify/lint* package.
202223
This package provides shared Deno Lint and ESLint configurations for
203-
consistent code style across Fedify packages and user projects.
224+
consistent code style across Fedify packages and user projects.
204225
[[#297], [#494] by ChanHaeng Lee]
205226

206227
### @fedify/fresh

docs/cli.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ The above command will start the interactive prompt to initialize a new Fedify
121121
project. It will ask you a few questions to set up the project:
122122

123123
- Package manager: [Deno], [Bun], [npm], [pnpm], or [Yarn]
124-
- Web framework: [Hono], [Express], [Nitro], or [Next.js]
124+
- Web framework: [Hono], [Elysia], [Express], [Nitro], or [Next.js]
125125
- key–value store: In-memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno)
126126
- Message queue: In-memory, [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]),
127127
or [Deno KV] (if Deno)
@@ -142,6 +142,7 @@ interactive prompts:
142142
[AMQP]: https://www.amqp.org/
143143
[RabbitMQ]: https://www.rabbitmq.com/
144144
[Deno KV]: https://deno.com/kv
145+
[Elysia]: https://elysiajs.com/
145146

146147
### `-r`/`--runtime`: JavaScript runtime
147148

@@ -173,6 +174,7 @@ the `-w`/`--web-framework` option. The available options are:
173174
- `hono`: [Hono]
174175
- `express`: [Express] (unless Deno)
175176
- `nitro`: [Nitro] (unless Deno)
177+
- `elysia`: [Elysia]
176178

177179
If it's omitted, no web framework will be integrated.
178180

docs/manual/integration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,23 @@ a seamless plugin for integrating Fedify with Elysia:
594594
bun add @fedify/elysia
595595
~~~~
596596

597+
~~~~ sh [Deno]
598+
deno add npm:@fedify/elysia
599+
~~~~
600+
601+
~~~~ sh [npm]
602+
npm add @fedify/elysia
603+
~~~~
604+
605+
~~~~ sh [pnpm]
606+
pnpm add @fedify/elysia
607+
~~~~
608+
609+
~~~~ sh [Yarn]
610+
yarn add @fedify/elysia
611+
~~~~
612+
613+
597614
~~~~ typescript
598615
import { fedify } from "@fedify/elysia";
599616
import { federation } from "./federation.ts"; // Your `Federation` instance

packages/cli/src/init/action/deps.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ export const joinDepsReg = (pm: PackageManager) => //
127127
pipe(
128128
dependencies,
129129
entries,
130-
map(([name, version]): [string, string] => [
131-
name.substring(4),
132-
`${name}@${getPackageVersion(pm, version)}`,
133-
]),
130+
map(([name, version]): [string, string] => {
131+
const cleanName = name.substring(4);
132+
// If version already contains a registry prefix (npm: or jsr:), use it as-is
133+
// Otherwise, construct the full spec from the name and version
134+
const fullSpec = version.startsWith("npm:") || version.startsWith("jsr:")
135+
? version
136+
: `${name}@${getPackageVersion(pm, version)}`;
137+
return [cleanName, fullSpec];
138+
}),
134139
fromEntries,
135140
);
136141

packages/cli/src/init/const.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
export const PACKAGE_MANAGER = ["deno", "pnpm", "bun", "yarn", "npm"] as const;
2-
export const WEB_FRAMEWORK = ["hono", "nitro", "next", "express"] as const;
2+
export const WEB_FRAMEWORK = [
3+
"hono",
4+
"nitro",
5+
"next",
6+
"elysia",
7+
"express",
8+
] as const;
39
export const MESSAGE_QUEUE = ["denokv", "redis", "postgres", "amqp"] as const;
410
export const KV_STORE = ["denokv", "redis", "postgres"] as const;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { fedify } from "@fedify/elysia";
2+
import { Elysia } from "elysia";
3+
import federation from "./federation.ts";
4+
import "./logging.ts";
5+
6+
const app = new Elysia();
7+
8+
app
9+
.use(fedify(federation, () => undefined))
10+
.get("/", () => "Hello, Fedify!")
11+
.listen(3000, () => {
12+
console.log("Server started at http://localhost:3000");
13+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { fedify } from "@fedify/elysia";
2+
import { Elysia } from "elysia";
3+
import federation from "./federation.ts";
4+
import "./logging.ts";
5+
6+
const app = new Elysia();
7+
8+
app
9+
.use(fedify(federation, () => undefined))
10+
.get("/", () => "Hello, Fedify!")
11+
12+
Deno.serve(
13+
{
14+
port: 3000,
15+
onListen: ({ port, hostname }) =>
16+
console.log("Server started at http://" + hostname + ":" + port),
17+
},
18+
app.fetch,
19+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { fedify } from "@fedify/elysia";
2+
import { Elysia } from "elysia";
3+
import federation from "./federation.ts";
4+
import "./logging.ts";
5+
import { node } from '@elysiajs/node'
6+
7+
const app = new Elysia({ adapter: node() });
8+
9+
app
10+
.use(fedify(federation, () => undefined))
11+
.get("/", () => "Hello, Fedify!")
12+
.listen(3000, () => {
13+
console.log("Server started at http://localhost:3000");
14+
})

packages/cli/src/init/webframeworks.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,76 @@ const webFrameworks: WebFrameworks = {
7979
}),
8080
defaultPort: 8000,
8181
},
82+
elysia: {
83+
label: "ElysiaJS",
84+
packageManagers: PACKAGE_MANAGER,
85+
init: ({ projectName, packageManager: pm }) => ({
86+
dependencies: pm === "deno"
87+
? {
88+
elysia: "npm:elysia@^1.3.6",
89+
"@fedify/elysia": PACKAGE_VERSION,
90+
}
91+
: pm === "bun"
92+
? {
93+
elysia: "^1.3.6",
94+
"@fedify/elysia": PACKAGE_VERSION,
95+
}
96+
: {
97+
elysia: "^1.3.6",
98+
"@elysiajs/node": "^1.4.2",
99+
"@fedify/elysia": PACKAGE_VERSION,
100+
...(pm === "pnpm"
101+
? {
102+
"@sinclair/typebox": "^0.34.41",
103+
"openapi-types": "^12.1.3",
104+
}
105+
: {}),
106+
},
107+
devDependencies: pm === "bun"
108+
? { "@types/bun": "^1.2.19" }
109+
: pm === "deno"
110+
? {}
111+
: {
112+
tsx: "^4.21.0",
113+
"@types/node": "^25.0.3",
114+
typescript: "^5.9.3",
115+
},
116+
federationFile: "src/federation.ts",
117+
loggingFile: "src/logging.ts",
118+
files: {
119+
"src/index.ts": readTemplate(
120+
`elysia/index/${packageManagerToRuntime(pm)}.ts`,
121+
).replace(/\/\* logger \*\//, projectName),
122+
},
123+
compilerOptions: pm === "deno" || pm === "bun" ? undefined : {
124+
"lib": ["ESNext", "DOM"],
125+
"target": "ESNext",
126+
"module": "NodeNext",
127+
"moduleResolution": "NodeNext",
128+
"allowImportingTsExtensions": true,
129+
"verbatimModuleSyntax": true,
130+
"noEmit": true,
131+
"strict": true,
132+
},
133+
tasks: {
134+
"dev": pm === "deno"
135+
? "deno serve --allow-env --allow-net --watch ./src/index.ts"
136+
: pm === "bun"
137+
? "bun run --hot ./src/index.ts"
138+
: "tsx watch src/index.ts",
139+
...(pm === "deno"
140+
? { "prod": "deno serve --allow-env --allow-net ./src/index.ts" }
141+
: pm === "bun"
142+
? { "prod": "bun run ./src/index.ts" }
143+
: {
144+
"build": "tsc src/index.ts --outDir dist",
145+
"start": "NODE_ENV=production node dist/index.js",
146+
}),
147+
},
148+
instruction: getInstruction(pm, 3000),
149+
}),
150+
defaultPort: 3000,
151+
},
82152
express: {
83153
label: "Express",
84154
packageManagers: PACKAGE_MANAGER,

packages/elysia/deno.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@fedify/elysia",
3+
"version": "2.0.0",
4+
"license": "MIT",
5+
"exports": {
6+
".": "./src/index.ts"
7+
},
8+
"exclude": [
9+
"dist",
10+
"node_modules"
11+
],
12+
"tasks": {
13+
"check": "deno fmt --check && deno lint && deno check src/*.ts"
14+
}
15+
}

0 commit comments

Comments
 (0)