Skip to content

Commit 2b6efe5

Browse files
authored
Merge pull request #729 from dahlia/bugfix/astro-logging
Load init logging on Fedify 2.1 templates
2 parents 9f47c27 + 2b8b320 commit 2b6efe5

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

CHANGES.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ To be released.
1010

1111
### @fedify/init
1212

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]]
13+
- Fixed the Astro, Nitro, and Next.js project templates so their generated
14+
*logging.ts* files are loaded during server startup before Fedify handles
15+
requests. Nitro projects now get a server plugin that imports the LogTape
16+
configuration, Next.js projects get an *instrumentation.ts* `register()`
17+
hook that imports it in the Node.js runtime, and Astro projects import it
18+
in *src/middleware.ts*. [[#725], [#727]]
1819

1920
[#725]: https://github.com/fedify-dev/fedify/issues/725
2021
[#727]: https://github.com/fedify-dev/fedify/pull/727

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

packages/init/src/webframeworks.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ok } from "node:assert/strict";
22
import test from "node:test";
3+
import astroDescription from "./webframeworks/astro.ts";
34
import nextDescription from "./webframeworks/next.ts";
45
import nitroDescription from "./webframeworks/nitro.ts";
56

@@ -44,3 +45,22 @@ test("Next.js template loads LogTape through instrumentation", async () => {
4445
ok(instrumentation.includes("process.env.NEXT_RUNTIME"));
4546
ok(instrumentation.includes('await import("./logging")'));
4647
});
48+
49+
test("Astro template loads LogTape through middleware", async () => {
50+
const { files } = await astroDescription.init({
51+
projectName: "test-app",
52+
dir: ".",
53+
command: "init",
54+
packageManager: "npm",
55+
kvStore: "in-memory",
56+
messageQueue: "in-process",
57+
webFramework: "astro",
58+
testMode: false,
59+
dryRun: true,
60+
});
61+
62+
ok(files);
63+
const middleware = files["src/middleware.ts"];
64+
ok(middleware);
65+
ok(middleware.includes('import "./logging.ts";'));
66+
});

0 commit comments

Comments
 (0)