File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ Version 2.0.15
88
99To 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
1223Version 2.0.14
1324--------------
Original file line number Diff line number Diff line change 1+ export async function register() {
2+ if (process.env.NEXT_RUNTIME === " nodejs" ) {
3+ await import(" ./logging" );
4+ }
5+ }
Original file line number Diff line number Diff line change 1+ import "../logging";
2+
3+ export default function setupLogging() { }
Original file line number Diff line number Diff line change 1+ import { ok } from "node:assert/strict" ;
2+ import test from "node:test" ;
3+ import webFrameworks from "./webframeworks.ts" ;
4+
5+ test ( "Nitro template loads LogTape during server startup" , async ( ) => {
6+ const { files } = await webFrameworks . nitro . init ( {
7+ projectName : "test-app" ,
8+ dir : "." ,
9+ command : "init" ,
10+ packageManager : "npm" ,
11+ kvStore : "in-memory" ,
12+ messageQueue : "in-process" ,
13+ webFramework : "nitro" ,
14+ testMode : false ,
15+ dryRun : true ,
16+ } ) ;
17+
18+ ok ( files ) ;
19+ ok ( "server/plugins/logging.ts" in files ) ;
20+ const plugin = files [ "server/plugins/logging.ts" ] ;
21+ ok ( plugin ) ;
22+ ok ( plugin . includes ( 'import "../logging";' ) ) ;
23+ } ) ;
24+
25+ test ( "Next.js template loads LogTape through instrumentation" , async ( ) => {
26+ const { files } = await webFrameworks . next . init ( {
27+ projectName : "test-app" ,
28+ dir : "." ,
29+ command : "init" ,
30+ packageManager : "npm" ,
31+ kvStore : "in-memory" ,
32+ messageQueue : "in-process" ,
33+ webFramework : "next" ,
34+ testMode : false ,
35+ dryRun : true ,
36+ } ) ;
37+
38+ ok ( files ) ;
39+ ok ( "instrumentation.ts" in files ) ;
40+ const instrumentation = files [ "instrumentation.ts" ] ;
41+ ok ( instrumentation ) ;
42+ ok ( instrumentation . includes ( "export async function register()" ) ) ;
43+ ok ( instrumentation . includes ( "process.env.NEXT_RUNTIME" ) ) ;
44+ ok ( instrumentation . includes ( 'await import("./logging")' ) ) ;
45+ } ) ;
Original file line number Diff line number Diff line change @@ -300,6 +300,9 @@ const webFrameworks: WebFrameworks = {
300300 federationFile : "server/federation.ts" ,
301301 loggingFile : "server/logging.ts" ,
302302 files : {
303+ "server/plugins/logging.ts" : await readTemplate (
304+ "nitro/server/plugins/logging.ts" ,
305+ ) ,
303306 "server/middleware/federation.ts" : await readTemplate (
304307 "nitro/server/middleware/federation.ts" ,
305308 ) ,
@@ -338,6 +341,7 @@ const webFrameworks: WebFrameworks = {
338341 federationFile : "federation/index.ts" ,
339342 loggingFile : "logging.ts" ,
340343 files : {
344+ "instrumentation.ts" : await readTemplate ( "next/instrumentation.ts" ) ,
341345 "middleware.ts" : await readTemplate ( "next/middleware.ts" ) ,
342346 ...( pm !== "deno"
343347 ? {
You can’t perform that action at this time.
0 commit comments