Add Nuxt as a web framework option in fedify init#675
Add Nuxt as a web framework option in fedify init#6752chanhaeng wants to merge 9 commits intofedify-dev:mainfrom
fedify init#675Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces the @fedify/nuxt package to provide seamless integration between Fedify and the Nuxt framework, alongside updates to the fedify init tool for project scaffolding. The review feedback correctly identifies a critical bug in the Nuxt middleware template where the request body is ignored during manual Request construction, suggesting the use of toWebRequest from h3 as a fix. Furthermore, the feedback recommends enabling the @fedify/nuxt module by default in generated projects to simplify the setup and points out a typo in the Node.js type definitions version.
| // Construct the full URL from headers | ||
| const proto = event.headers.get("x-forwarded-proto") || "http"; | ||
| const host = event.headers.get("host") || "localhost"; | ||
| const url = new URL(event.node.req.url || "", `${proto}://${host}`); | ||
|
|
||
| const request = new Request(url, { | ||
| method: event.node.req.method, | ||
| headers: event.node.req.headers as Record<string, string>, | ||
| body: ["GET", "HEAD", "DELETE"].includes(event.node.req.method) | ||
| ? undefined | ||
| : undefined, | ||
| }); |
There was a problem hiding this comment.
The manual construction of the Request object is incomplete and contains a bug: the body is always set to undefined (lines 13-15), which will break ActivityPub inbox listeners that rely on POST requests.
Using toWebRequest(event) from h3 is the recommended approach as it correctly handles URL construction (including proxy headers), headers, and body streaming, while significantly simplifying the code.
const request = toWebRequest(event);
| devDependencies: { | ||
| ...defaultDevDependencies, | ||
| "typescript": deps["npm:typescript"], | ||
| "@types/node": deps["npm:@types/node@25"], |
There was a problem hiding this comment.
The key npm:@types/node@25 appears to be a typo. Node.js versions currently go up to 23, and the monorepo uses ^22.17.0 (as seen in pnpm-workspace.yaml). This will likely result in an undefined value if the key does not exist in deps.json, causing issues in the scaffolded project.
"@types/node": deps["npm:@types/node"],| @@ -0,0 +1,24 @@ | |||
| import { defineEventHandler } from "h3"; | |||
| export default defineNuxtConfig({ | ||
| ssr: false, | ||
| devtools: { enabled: true }, | ||
| }); |
There was a problem hiding this comment.
The @fedify/nuxt module is installed as a dependency but not enabled in the generated configuration. Enabling the module is the preferred integration method as it provides features like deferred 406 Not Acceptable handling and automatic middleware registration.
If the module is enabled, the manual middleware in server/middleware/federation.ts becomes redundant and should be removed from the template set in packages/init/src/webframeworks/nuxt.ts to avoid duplicate request handling.
export default defineNuxtConfig({
modules: ["@fedify/nuxt"],
ssr: false,
devtools: { enabled: true },
});
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
- Use @fedify/fixture instead of node:test in mod.test.ts - Type event parameter as H3Event instead of unknown in middleware.ts Co-Authored-By: Claude (claude-opus-4-20250514)
Move NOT_ACCEPTABLE_BODY and DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY into a shared lib.ts to avoid string duplication across logic.ts and plugin.ts. Co-Authored-By: Claude (claude-opus-4-20250514)
Add Nuxt as a web framework option in
fedify initDepends on #674.
Changes
@fedify/initfedify init.Users can now scaffold a new Fedify project with Nuxt integration
across all supported package managers (npm, pnpm, yarn, Bun, Deno).
New files
src/webframeworks/nuxt.ts:WebFrameworkDescriptionfor Nuxt,including
nuxi initscaffolding command, dependency resolution forboth Node.js and Deno environments, and template file mapping.
src/templates/nuxt/nuxt.config.ts.tpl: Minimal Nuxt configtemplate with SSR disabled and devtools enabled.
src/templates/nuxt/server/federation.ts.tpl: Federationinstance setup with
MemoryKvStoreand a basic actor dispatcher.src/templates/nuxt/server/logging.ts.tpl: LogTapeconfiguration for Nuxt and Fedify loggers.
src/templates/nuxt/server/middleware/federation.ts.tpl: Nitroevent handler that delegates requests to
federation.fetch(),falling through to Nuxt on 404.
Modified files
src/const.ts: Added"nuxt"to theWEB_FRAMEWORKarray.src/webframeworks/mod.ts: Imported and registered the Nuxtframework description.
src/json/deps.json: Added@nuxt/kit,h3,nuxi, andnuxtversion pins.src/test/port.ts: Added port replacement logic for Nuxt(injects
nitro.portintonuxt.config.ts).Co-Authored-By: GPT-5.4