Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ To be released.

### @fedify/init

- Fixed the Nitro and Next.js project templates so their generated
- Fixed the Astro, Nitro, and Next.js project templates so their generated
*logging.ts* files are loaded during server startup. Nitro projects now
get a server plugin that imports the LogTape configuration, and Next.js
get a server plugin that imports the LogTape configuration, Next.js
projects get an *instrumentation.ts* `register()` hook that imports it in
the Node.js runtime before Fedify handles requests. [[#725], [#727]]
the Node.js runtime, and Astro projects import it from *src/middleware.ts*
before Fedify handles requests. [[#725], [#727]]
Comment thread
dahlia marked this conversation as resolved.
Outdated

[#725]: https://github.com/fedify-dev/fedify/issues/725
[#727]: https://github.com/fedify-dev/fedify/pull/727
Expand Down
1 change: 1 addition & 0 deletions packages/init/src/templates/astro/src/middleware.ts.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./logging.ts";
import { fedifyMiddleware } from "@fedify/astro";
import federation from "./federation.ts";

Expand Down
20 changes: 20 additions & 0 deletions packages/init/src/webframeworks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ok } from "node:assert/strict";
import test from "node:test";
import astroDescription from "./webframeworks/astro.ts";
import nextDescription from "./webframeworks/next.ts";
import nitroDescription from "./webframeworks/nitro.ts";

Expand Down Expand Up @@ -44,3 +45,22 @@ test("Next.js template loads LogTape through instrumentation", async () => {
ok(instrumentation.includes("process.env.NEXT_RUNTIME"));
ok(instrumentation.includes('await import("./logging")'));
});

test("Astro template loads LogTape through middleware", async () => {
const { files } = await astroDescription.init({
projectName: "test-app",
dir: ".",
command: "init",
packageManager: "npm",
kvStore: "in-memory",
messageQueue: "in-process",
webFramework: "astro",
testMode: false,
dryRun: true,
});

ok(files);
const middleware = files["src/middleware.ts"];
ok(middleware);
ok(middleware.includes('import "./logging.ts";'));
});
Loading