Skip to content

Commit 9f47c27

Browse files
committed
Merge branch '2.0-maintenance' into 2.1-maintenance
2 parents af8a37a + 1cb9a6b commit 9f47c27

6 files changed

Lines changed: 83 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ Version 2.1.11
88

99
To be released.
1010

11+
### @fedify/init
12+
13+
- Fixed the Nitro and Next.js project templates so their generated
14+
*logging.ts* files are loaded during server startup. Nitro projects now
15+
get a server plugin that imports the LogTape configuration, and Next.js
16+
projects get an *instrumentation.ts* `register()` hook that imports it in
17+
the Node.js runtime before Fedify handles requests. [[#725], [#727]]
18+
19+
[#725]: https://github.com/fedify-dev/fedify/issues/725
20+
[#727]: https://github.com/fedify-dev/fedify/pull/727
21+
1122

1223
Version 2.1.10
1324
--------------
@@ -440,6 +451,20 @@ Released on March 24, 2026.
440451
[#599]: https://github.com/fedify-dev/fedify/pull/599
441452

442453

454+
Version 2.0.15
455+
--------------
456+
457+
To be released.
458+
459+
### @fedify/init
460+
461+
- Fixed the Nitro and Next.js project templates so their generated
462+
*logging.ts* files are loaded during server startup. Nitro projects now
463+
get a server plugin that imports the LogTape configuration, and Next.js
464+
projects get an *instrumentation.ts* `register()` hook that imports it in
465+
the Node.js runtime before Fedify handles requests. [[#725], [#727]]
466+
467+
443468
Version 2.0.14
444469
--------------
445470

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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { ok } from "node:assert/strict";
2+
import test from "node:test";
3+
import nextDescription from "./webframeworks/next.ts";
4+
import nitroDescription from "./webframeworks/nitro.ts";
5+
6+
test("Nitro template loads LogTape during server startup", async () => {
7+
const { files } = await nitroDescription.init({
8+
projectName: "test-app",
9+
dir: ".",
10+
command: "init",
11+
packageManager: "npm",
12+
kvStore: "in-memory",
13+
messageQueue: "in-process",
14+
webFramework: "nitro",
15+
testMode: false,
16+
dryRun: true,
17+
});
18+
19+
ok(files);
20+
ok("server/plugins/logging.ts" in files);
21+
const plugin = files["server/plugins/logging.ts"];
22+
ok(plugin);
23+
ok(plugin.includes('import "../logging";'));
24+
});
25+
26+
test("Next.js template loads LogTape through instrumentation", async () => {
27+
const { files } = await nextDescription.init({
28+
projectName: "test-app",
29+
dir: ".",
30+
command: "init",
31+
packageManager: "npm",
32+
kvStore: "in-memory",
33+
messageQueue: "in-process",
34+
webFramework: "next",
35+
testMode: false,
36+
dryRun: true,
37+
});
38+
39+
ok(files);
40+
ok("instrumentation.ts" in files);
41+
const instrumentation = files["instrumentation.ts"];
42+
ok(instrumentation);
43+
ok(instrumentation.includes("export async function register()"));
44+
ok(instrumentation.includes("process.env.NEXT_RUNTIME"));
45+
ok(instrumentation.includes('await import("./logging")'));
46+
});

packages/init/src/webframeworks/next.ts

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

packages/init/src/webframeworks/nitro.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const nitroDescription: WebFrameworkDescription = {
1818
federationFile: "server/federation.ts",
1919
loggingFile: "server/logging.ts",
2020
files: {
21+
"server/plugins/logging.ts": await readTemplate(
22+
"nitro/server/plugins/logging.ts",
23+
),
2124
"server/middleware/federation.ts": await readTemplate(
2225
"nitro/server/middleware/federation.ts",
2326
),

0 commit comments

Comments
 (0)