diff --git a/CHANGES.md b/CHANGES.md index 5ce8ba4f8..64a1814c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -96,8 +96,10 @@ 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 @@ -105,9 +107,9 @@ To be released. [#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 @@ -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 @@ -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 @@ -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 diff --git a/docs/cli.md b/docs/cli.md index 3bbbb592b..503b262c5 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -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) @@ -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 @@ -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. diff --git a/docs/manual/integration.md b/docs/manual/integration.md index 16fca27df..89f2d7122 100644 --- a/docs/manual/integration.md +++ b/docs/manual/integration.md @@ -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 diff --git a/packages/cli/src/init/action/deps.ts b/packages/cli/src/init/action/deps.ts index 1ebe53e7e..adf712e0c 100644 --- a/packages/cli/src/init/action/deps.ts +++ b/packages/cli/src/init/action/deps.ts @@ -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, ); diff --git a/packages/cli/src/init/const.ts b/packages/cli/src/init/const.ts index cdbd85605..2b43ffcb2 100644 --- a/packages/cli/src/init/const.ts +++ b/packages/cli/src/init/const.ts @@ -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; diff --git a/packages/cli/src/init/templates/elysia/index/bun.ts.tpl b/packages/cli/src/init/templates/elysia/index/bun.ts.tpl new file mode 100644 index 000000000..a876ae50f --- /dev/null +++ b/packages/cli/src/init/templates/elysia/index/bun.ts.tpl @@ -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"); + }) diff --git a/packages/cli/src/init/templates/elysia/index/deno.ts.tpl b/packages/cli/src/init/templates/elysia/index/deno.ts.tpl new file mode 100644 index 000000000..94d18e24d --- /dev/null +++ b/packages/cli/src/init/templates/elysia/index/deno.ts.tpl @@ -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, +) diff --git a/packages/cli/src/init/templates/elysia/index/node.ts.tpl b/packages/cli/src/init/templates/elysia/index/node.ts.tpl new file mode 100644 index 000000000..04a5ed6fa --- /dev/null +++ b/packages/cli/src/init/templates/elysia/index/node.ts.tpl @@ -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"); + }) diff --git a/packages/cli/src/init/webframeworks.ts b/packages/cli/src/init/webframeworks.ts index d29ab616c..abc7f0b1b 100644 --- a/packages/cli/src/init/webframeworks.ts +++ b/packages/cli/src/init/webframeworks.ts @@ -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, diff --git a/packages/elysia/deno.json b/packages/elysia/deno.json new file mode 100644 index 000000000..1a5e1a3cc --- /dev/null +++ b/packages/elysia/deno.json @@ -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" + } +}