Skip to content

Commit cb3394b

Browse files
committed
Merge branch '2.1-maintenance'
2 parents 9b1a1c0 + 2b6efe5 commit cb3394b

8 files changed

Lines changed: 118 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,24 @@ To be released.
262262
[#722]: https://github.com/fedify-dev/fedify/pull/722
263263

264264

265+
Version 2.1.11
266+
--------------
267+
268+
To be released.
269+
270+
### @fedify/init
271+
272+
- Fixed the Astro, Nitro, and Next.js project templates so their generated
273+
*logging.ts* files are loaded during server startup before Fedify handles
274+
requests. Nitro projects now get a server plugin that imports the LogTape
275+
configuration, Next.js projects get an *instrumentation.ts* `register()`
276+
hook that imports it in the Node.js runtime, and Astro projects import it
277+
in *src/middleware.ts*. [[#725], [#727]]
278+
279+
[#725]: https://github.com/fedify-dev/fedify/issues/725
280+
[#727]: https://github.com/fedify-dev/fedify/pull/727
281+
282+
265283
Version 2.1.10
266284
--------------
267285

@@ -691,6 +709,20 @@ Released on March 24, 2026.
691709
[#599]: https://github.com/fedify-dev/fedify/pull/599
692710

693711

712+
Version 2.0.15
713+
--------------
714+
715+
To be released.
716+
717+
### @fedify/init
718+
719+
- Fixed the Nitro and Next.js project templates so their generated
720+
*logging.ts* files are loaded during server startup. Nitro projects now
721+
get a server plugin that imports the LogTape configuration, and Next.js
722+
projects get an *instrumentation.ts* `register()` hook that imports it in
723+
the Node.js runtime before Fedify handles requests. [[#725], [#727]]
724+
725+
694726
Version 2.0.14
695727
--------------
696728

deno.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/init/src/templates/astro/src/middleware.ts.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./logging.ts";
12
import { fedifyMiddleware } from "@fedify/astro";
23
import federation from "./federation.ts";
34

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export async function register() {
2+
if (process.env.NEXT_RUNTIME === "nodejs") {
3+
await import("./logging");
4+
}
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import "../logging";
2+
3+
export default function setupLogging() {}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { ok } from "node:assert/strict";
2+
import test from "node:test";
3+
import astroDescription from "./webframeworks/astro.ts";
4+
import nextDescription from "./webframeworks/next.ts";
5+
import nitroDescription from "./webframeworks/nitro.ts";
6+
7+
test("Nitro template loads LogTape during server startup", async () => {
8+
const { files } = await nitroDescription.init({
9+
projectName: "test-app",
10+
dir: ".",
11+
command: "init",
12+
packageManager: "npm",
13+
kvStore: "in-memory",
14+
messageQueue: "in-process",
15+
webFramework: "nitro",
16+
testMode: false,
17+
dryRun: true,
18+
allowNonEmpty: false,
19+
});
20+
21+
ok(files);
22+
ok("server/plugins/logging.ts" in files);
23+
const plugin = files["server/plugins/logging.ts"];
24+
ok(plugin);
25+
ok(plugin.includes('import "../logging";'));
26+
});
27+
28+
test("Next.js template loads LogTape through instrumentation", async () => {
29+
const { files } = await nextDescription.init({
30+
projectName: "test-app",
31+
dir: ".",
32+
command: "init",
33+
packageManager: "npm",
34+
kvStore: "in-memory",
35+
messageQueue: "in-process",
36+
webFramework: "next",
37+
testMode: false,
38+
dryRun: true,
39+
allowNonEmpty: false,
40+
});
41+
42+
ok(files);
43+
ok("instrumentation.ts" in files);
44+
const instrumentation = files["instrumentation.ts"];
45+
ok(instrumentation);
46+
ok(instrumentation.includes("export async function register()"));
47+
ok(instrumentation.includes("process.env.NEXT_RUNTIME"));
48+
ok(instrumentation.includes('await import("./logging")'));
49+
});
50+
51+
test("Astro template loads LogTape through middleware", async () => {
52+
const { files } = await astroDescription.init({
53+
projectName: "test-app",
54+
dir: ".",
55+
command: "init",
56+
packageManager: "npm",
57+
kvStore: "in-memory",
58+
messageQueue: "in-process",
59+
webFramework: "astro",
60+
testMode: false,
61+
dryRun: true,
62+
allowNonEmpty: false,
63+
});
64+
65+
ok(files);
66+
const middleware = files["src/middleware.ts"];
67+
ok(middleware);
68+
ok(middleware.includes('import "./logging.ts";'));
69+
});

packages/init/src/webframeworks/next.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const nextDescription: WebFrameworkDescription = {
2222
federationFile: "federation/index.ts",
2323
loggingFile: "logging.ts",
2424
files: {
25+
"instrumentation.ts": await readTemplate("next/instrumentation.ts"),
2526
"middleware.ts": await readTemplate("next/middleware.ts"),
2627
...(pm !== "deno" && {
2728
"eslint.config.ts": await readTemplate("defaults/eslint.config.ts"),

packages/init/src/webframeworks/nitro.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const nitroDescription: WebFrameworkDescription = {
1919
loggingFile: "server/logging.ts",
2020
env: testMode ? { HOST: "127.0.0.1" } : {} as Record<string, string>,
2121
files: {
22+
"server/plugins/logging.ts": await readTemplate(
23+
"nitro/server/plugins/logging.ts",
24+
),
2225
"server/middleware/federation.ts": await readTemplate(
2326
"nitro/server/middleware/federation.ts",
2427
),

0 commit comments

Comments
 (0)