Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ To be released.
already support this method. [[#499], [#506]]

[#280]: https://github.com/fedify-dev/fedify/issues/280
[#297]: https://github.com/fedify-dev/fedify/issues/297
[#366]: https://github.com/fedify-dev/fedify/issues/366
[#376]: https://github.com/fedify-dev/fedify/issues/376
[#391]: https://github.com/fedify-dev/fedify/pull/391
[#392]: https://github.com/fedify-dev/fedify/pull/392
[#393]: https://github.com/fedify-dev/fedify/pulls/393
[#433]: https://github.com/fedify-dev/fedify/pull/433
[#434]: https://github.com/fedify-dev/fedify/pull/434
[#444]: https://github.com/fedify-dev/fedify/issues/444
[#445]: https://github.com/fedify-dev/fedify/pull/445
[#451]: https://github.com/fedify-dev/fedify/pull/451
[#391]: https://github.com/fedify-dev/fedify/pull/391
[#466]: https://github.com/fedify-dev/fedify/issues/466
[#499]: https://github.com/fedify-dev/fedify/issues/499
[#494]: https://github.com/fedify-dev/fedify/pull/494
[#506]: https://github.com/fedify-dev/fedify/pull/506

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

- The `fedify init` command now supports [Elysia] as a web framework option,
with runtime-specific templates for Deno, Bun, and Node.js environments.
[[#460], [#496] by Hyeonseo Kim]

- Fixed a bug in the `fedify init` command where Deno import map generation
incorrectly handled dependencies with registry prefixes (e.g., `npm:`),
creating invalid specifiers in *deno.json*. [[#460], [#496] by Hyeonseo Kim]

[Elysia]: https://elysiajs.com/
[#374]: https://github.com/fedify-dev/fedify/issues/374
[#397]: https://github.com/fedify-dev/fedify/issues/397
[#408]: https://github.com/fedify-dev/fedify/issues/408
Expand All @@ -141,6 +152,8 @@ To be released.
[#456]: https://github.com/fedify-dev/fedify/issues/456
[#457]: https://github.com/fedify-dev/fedify/pull/457
[#458]: https://github.com/fedify-dev/fedify/pull/458
[#460]: https://github.com/fedify-dev/fedify/issues/460
[#496]: https://github.com/fedify-dev/fedify/pull/496

### @fedify/relay

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

### @fedify/elysia

- Added *deno.json* configuration file to enable proper Deno tooling support
in the package. [[#460], [#496]]

[#460]: https://github.com/fedify-dev/fedify/issues/460
[#496]: https://github.com/fedify-dev/fedify/pull/496

### @fedify/lint

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

### @fedify/fresh
Expand Down
4 changes: 3 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The above command will start the interactive prompt to initialize a new Fedify
project. It will ask you a few questions to set up the project:

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

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

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

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

Expand Down
17 changes: 17 additions & 0 deletions docs/manual/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,23 @@ a seamless plugin for integrating Fedify with Elysia:
bun add @fedify/elysia
~~~~

~~~~ sh [Deno]
deno add npm:@fedify/elysia
~~~~

~~~~ sh [npm]
npm add @fedify/elysia
~~~~

~~~~ sh [pnpm]
pnpm add @fedify/elysia
~~~~

~~~~ sh [Yarn]
yarn add @fedify/elysia
~~~~


~~~~ typescript
import { fedify } from "@fedify/elysia";
import { federation } from "./federation.ts"; // Your `Federation` instance
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/src/init/action/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,15 @@ export const joinDepsReg = (pm: PackageManager) => //
pipe(
dependencies,
entries,
map(([name, version]): [string, string] => [
name.substring(4),
`${name}@${getPackageVersion(pm, version)}`,
]),
map(([name, version]): [string, string] => {
const cleanName = name.substring(4);
// If version already contains a registry prefix (npm: or jsr:), use it as-is
// Otherwise, construct the full spec from the name and version
const fullSpec = version.startsWith("npm:") || version.startsWith("jsr:")
? version
: `${name}@${getPackageVersion(pm, version)}`;
return [cleanName, fullSpec];
}),
fromEntries,
);

Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/init/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export const PACKAGE_MANAGER = ["deno", "pnpm", "bun", "yarn", "npm"] as const;
export const WEB_FRAMEWORK = ["hono", "nitro", "next", "express"] as const;
export const WEB_FRAMEWORK = [
"hono",
"nitro",
"next",
"elysia",
"express",
] as const;
export const MESSAGE_QUEUE = ["denokv", "redis", "postgres", "amqp"] as const;
export const KV_STORE = ["denokv", "redis", "postgres"] as const;
13 changes: 13 additions & 0 deletions packages/cli/src/init/templates/elysia/index/bun.ts.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { fedify } from "@fedify/elysia";
import { Elysia } from "elysia";
import federation from "./federation.ts";
import "./logging.ts";

const app = new Elysia();

app
.use(fedify(federation, () => undefined))
.get("/", () => "Hello, Fedify!")
.listen(3000, () => {
console.log("Server started at http://localhost:3000");
})
19 changes: 19 additions & 0 deletions packages/cli/src/init/templates/elysia/index/deno.ts.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { fedify } from "@fedify/elysia";
import { Elysia } from "elysia";
import federation from "./federation.ts";
import "./logging.ts";

const app = new Elysia();

app
.use(fedify(federation, () => undefined))
.get("/", () => "Hello, Fedify!")

Deno.serve(
{
port: 3000,
onListen: ({ port, hostname }) =>
console.log("Server started at http://" + hostname + ":" + port),
},
app.fetch,
)
14 changes: 14 additions & 0 deletions packages/cli/src/init/templates/elysia/index/node.ts.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { fedify } from "@fedify/elysia";
import { Elysia } from "elysia";
import federation from "./federation.ts";
import "./logging.ts";
import { node } from '@elysiajs/node'

const app = new Elysia({ adapter: node() });

app
.use(fedify(federation, () => undefined))
.get("/", () => "Hello, Fedify!")
.listen(3000, () => {
console.log("Server started at http://localhost:3000");
})
70 changes: 70 additions & 0 deletions packages/cli/src/init/webframeworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,76 @@ const webFrameworks: WebFrameworks = {
}),
defaultPort: 8000,
},
elysia: {
label: "ElysiaJS",
packageManagers: PACKAGE_MANAGER,
init: ({ projectName, packageManager: pm }) => ({
dependencies: pm === "deno"
? {
elysia: "npm:elysia@^1.3.6",
"@fedify/elysia": PACKAGE_VERSION,
}
: pm === "bun"
? {
elysia: "^1.3.6",
"@fedify/elysia": PACKAGE_VERSION,
}
: {
elysia: "^1.3.6",
"@elysiajs/node": "^1.4.2",
"@fedify/elysia": PACKAGE_VERSION,
...(pm === "pnpm"
? {
"@sinclair/typebox": "^0.34.41",
"openapi-types": "^12.1.3",
}
: {}),
},
devDependencies: pm === "bun"
? { "@types/bun": "^1.2.19" }
: pm === "deno"
? {}
: {
tsx: "^4.21.0",
"@types/node": "^25.0.3",
typescript: "^5.9.3",
},
federationFile: "src/federation.ts",
loggingFile: "src/logging.ts",
files: {
"src/index.ts": readTemplate(
`elysia/index/${packageManagerToRuntime(pm)}.ts`,
).replace(/\/\* logger \*\//, projectName),
},
compilerOptions: pm === "deno" || pm === "bun" ? undefined : {
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"strict": true,
},
tasks: {
"dev": pm === "deno"
? "deno serve --allow-env --allow-net --watch ./src/index.ts"
: pm === "bun"
? "bun run --hot ./src/index.ts"
: "tsx watch src/index.ts",
...(pm === "deno"
? { "prod": "deno serve --allow-env --allow-net ./src/index.ts" }
: pm === "bun"
? { "prod": "bun run ./src/index.ts" }
: {
"build": "tsc src/index.ts --outDir dist",
"start": "NODE_ENV=production node dist/index.js",
}),
},
instruction: getInstruction(pm, 3000),
}),
defaultPort: 3000,
},
express: {
label: "Express",
packageManagers: PACKAGE_MANAGER,
Expand Down
15 changes: 15 additions & 0 deletions packages/elysia/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@fedify/elysia",
"version": "2.0.0",
"license": "MIT",
"exports": {
".": "./src/index.ts"
},
"exclude": [
"dist",
"node_modules"
],
"tasks": {
"check": "deno fmt --check && deno lint && deno check src/*.ts"
}
}
Loading