-
Notifications
You must be signed in to change notification settings - Fork 81
refactor(webui): Complete migration to new Fastify Architecture by removing log-viewer-webui
Fastify app.
#1106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
## Walkthrough
This change consolidates the Fastify server setup by replacing the previous `fastify-v2/app.ts` with a new `app.ts` that registers plugins and routes using `fastifyAutoload`, sets unified error and 404 handlers, and updates script paths and import statements throughout the codebase to reflect the new structure. Several import paths are also simplified.
## Changes
| File(s) | Change Summary |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| package.json, src/main.ts | Updated server start script and import paths to use new `app.ts` entrypoint. |
| src/app.ts, src/fastify-v2/app.ts (deleted) | Replaced old Fastify app with new consolidated async function for plugin/route registration and error handling. |
| src/routes/static.ts | Static file serving is now always registered, not just in production; removed `process` import. |
| src/plugins/app/QueryJobDbManager/index.ts, src/plugins/app/S3Manager/index.ts, src/plugins/app/StreamFileManager.ts | Simplified and corrected relative import paths for settings, typings, and modules. |
| src/plugins/external/mongo.ts, src/plugins/external/mysql.ts | Updated import paths for `settings.json` to be less nested. |
| src/routes/api/search/index.ts, src/routes/api/search/utils.ts, src/routes/api/search/typings.ts | Shortened import paths for constants, schemas, and settings. |
| src/routes/api/stream-files/index.ts, src/schemas/stream-files.ts | Adjusted import paths for job types, schemas, and settings. |
| src/plugins/app/socket/MongoSocketIoServer/index.ts, src/plugins/app/socket/MongoSocketIoServer/typings.ts, src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts | Shortened import paths for types and modules. |
| src/test/example.test.ts | Updated import path for route under test. |
| src/test/tap.ts | Removed obsolete TODO comments about Fastify app and test splitting. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant FastifyServer
participant PluginLoader
participant RouteLoader
User->>FastifyServer: Start server (via app.ts)
FastifyServer->>PluginLoader: Register external plugins
PluginLoader-->>FastifyServer: Plugins registered
FastifyServer->>PluginLoader: Register app plugins
PluginLoader-->>FastifyServer: App plugins registered
FastifyServer->>RouteLoader: Register routes
RouteLoader-->>FastifyServer: Routes registered
FastifyServer->>User: Serve requests, handle errors and 404s Possibly related PRs
Suggested reviewers
Learnt from: junhaoliao
Learnt from: junhaoliao
Learnt from: davemarco
Learnt from: junhaoliao
Learnt from: junhaoliao
Learnt from: davemarco
Learnt from: junhaoliao
Learnt from: junhaoliao
|
log-viewer-webui
Fastify app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🔭 Outside diff range comments (5)
components/webui/server/src/plugins/app/S3Manager/index.ts (1)
53-56
:false === error instanceof Error
is hard to parseWhile this meets the house rule of avoiding
!expr
, a clearer strict-equality form is:-if (false === error instanceof Error) { +if (error instanceof Error === false) {or simply invert the condition and early-return for readability. Consider codifying this rule in an ESLint preset so future contributors don’t need to remember it manually.
components/webui/server/src/main.ts (1)
47-55
: Wrapapp.close()
in atry/catch
to avoid unhandled promise rejections
app.close()
can reject if any plugin’sonClose
hook fails.
Without a guard, the process may hang or exit with an unhandled-rejection warning.- closeWithGrace( - {delay: Number(DEFAULT_FASTIFY_CLOSE_GRACE_DELAY)}, - async ({err}) => { - if (err) { - app.log.error(err); - } - - await app.close(); - } - ); + closeWithGrace( + {delay: Number(DEFAULT_FASTIFY_CLOSE_GRACE_DELAY)}, + async ({err}) => { + if (err) { + app.log.error(err); + } + + try { + await app.close(); + } catch (closeErr) { + app.log.error(closeErr, "Error during graceful shutdown"); + process.exitCode = 1; + } + } + );components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts (1)
56-64
:hasWatcher
can be simplified withMap.has
Current implementation performs an unnecessary lookup &
typeof
check.- hasWatcher ( - queryId: QueryId, - ): boolean { - if ("undefined" === typeof this.#queryIdtoWatcherMap.get(queryId)) { - return false; - } - - return true; - } + hasWatcher (queryId: QueryId): boolean { + return this.#queryIdtoWatcherMap.has(queryId); + }components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts (1)
17-25
: Same maintainability concern about long relative path
../../../../../../common/index.js
is already six hops up; a path alias would make the intent clearer and avoid accidental breakage if folders move again.components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts (1)
9-15
: Mirror the alias change here for consistency
If you adopt an alias in the main socket server file, update this import too so both files stay in sync.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (20)
components/webui/server/package.json
(1 hunks)components/webui/server/src/app.ts
(1 hunks)components/webui/server/src/fastify-v2/app.ts
(0 hunks)components/webui/server/src/main.ts
(1 hunks)components/webui/server/src/plugins/app/QueryJobDbManager/index.ts
(1 hunks)components/webui/server/src/plugins/app/S3Manager/index.ts
(1 hunks)components/webui/server/src/plugins/app/StreamFileManager.ts
(1 hunks)components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts
(1 hunks)components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts
(1 hunks)components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts
(1 hunks)components/webui/server/src/plugins/external/mongo.ts
(1 hunks)components/webui/server/src/plugins/external/mysql.ts
(1 hunks)components/webui/server/src/routes/api/search/index.ts
(1 hunks)components/webui/server/src/routes/api/search/typings.ts
(1 hunks)components/webui/server/src/routes/api/search/utils.ts
(1 hunks)components/webui/server/src/routes/api/stream-files/index.ts
(1 hunks)components/webui/server/src/routes/static.ts
(1 hunks)components/webui/server/src/schemas/stream-files.ts
(1 hunks)components/webui/server/src/test/example.test.ts
(1 hunks)components/webui/server/src/test/tap.ts
(0 hunks)
💤 Files with no reviewable changes (2)
- components/webui/server/src/test/tap.ts
- components/webui/server/src/fastify-v2/app.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
🧠 Learnings (19)
📓 Common learnings
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: gibber9809
PR: y-scope/clp#504
File: components/core/src/clp_s/search/kql/CMakeLists.txt:29-29
Timestamp: 2024-10-22T15:36:04.655Z
Learning: When reviewing pull requests, focus on the changes within the PR and avoid commenting on issues outside the scope of the PR.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
components/webui/server/src/main.ts (5)
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: In Fastify applications, the `app.close()` method returns a Promise that can reject if errors occur during shutdown. Always wrap it in a try/catch block to properly handle shutdown errors and set the process exit code to prevent the application from hanging.
components/webui/server/src/plugins/app/S3Manager/index.ts (3)
Learnt from: haiqi96
PR: y-scope/clp#673
File: components/log-viewer-webui/server/src/routes/query.js:9-10
Timestamp: 2025-01-17T22:33:23.547Z
Learning: When initializing S3Manager in log-viewer-webui, both StreamFilesS3Region and StreamFilesS3PathPrefix settings must be non-null for S3 functionality to work correctly.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts (4)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#880
File: components/log-viewer-webui/server/src/plugins/MongoSocketIoServer/MongoWatcherCollection.ts:79-83
Timestamp: 2025-05-05T18:03:50.472Z
Learning: In MongoWatcherCollection, the unsubscribe method is intentionally designed to remove only one instance of a connection ID from the subscribers array using removeItemFromArray. This allows for multiple subscriptions from the same connection, with each unsubscribe call removing only one subscription at a time.
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:32-38
Timestamp: 2025-05-09T18:05:42.814Z
Learning: When implementing Socket.IO namespaces or connection pooling in a client-server architecture (like the MongoDB collection socket system in the log-viewer-webui), coordinated changes are needed on both client and server sides, making it appropriate to track as a TODO rather than implement piecemeal.
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:27-31
Timestamp: 2025-05-09T19:15:26.180Z
Learning: For the MongoDB real-time updates implementation in components/log-viewer-webui/client/src/api/socket, a socket singleton pattern is used where a single shared socket connection is maintained rather than creating multiple connections. The socket lifecycle is managed centrally, with unsubscription handling in the useCursor React hook's cleanup function.
components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts (5)
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:32-38
Timestamp: 2025-05-09T18:05:42.814Z
Learning: When implementing Socket.IO namespaces or connection pooling in a client-server architecture (like the MongoDB collection socket system in the log-viewer-webui), coordinated changes are needed on both client and server sides, making it appropriate to track as a TODO rather than implement piecemeal.
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:27-31
Timestamp: 2025-05-09T19:15:26.180Z
Learning: For the MongoDB real-time updates implementation in components/log-viewer-webui/client/src/api/socket, a socket singleton pattern is used where a single shared socket connection is maintained rather than creating multiple connections. The socket lifecycle is managed centrally, with unsubscription handling in the useCursor React hook's cleanup function.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: davemarco
PR: y-scope/clp#880
File: components/log-viewer-webui/server/src/plugins/MongoSocketIoServer/MongoWatcherCollection.ts:79-83
Timestamp: 2025-05-05T18:03:50.472Z
Learning: In MongoWatcherCollection, the unsubscribe method is intentionally designed to remove only one instance of a connection ID from the subscribers array using removeItemFromArray. This allows for multiple subscriptions from the same connection, with each unsubscribe call removing only one subscription at a time.
components/webui/server/src/test/example.test.ts (6)
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: davemarco
PR: y-scope/clp#797
File: components/log-viewer-webui/client/src/components/Layout/MainLayout.tsx:2-5
Timestamp: 2025-04-08T22:32:05.366Z
Learning: In this codebase using React Router v7.4.1, components should be imported directly from "react-router" (e.g., `import { Link, Outlet } from "react-router";`) rather than from "react-router-dom" as was common in previous versions of React Router.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#797
File: components/log-viewer-webui/client/src/components/Layout/MainLayout.tsx:2-5
Timestamp: 2025-04-08T22:32:05.367Z
Learning: React Router v7.4.1 uses a different package structure than previous versions. Components can be imported directly from "react-router" (e.g., `import { Link, Outlet } from "react-router";`) rather than from "react-router-dom" as was common in previous versions. Alternatively, DOM-specific components can also be imported using deep imports like `import { Link } from "react-router/dom";`.
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: davemarco
PR: y-scope/clp#797
File: components/log-viewer-webui/client/src/routes/routes.tsx:1-1
Timestamp: 2025-04-04T15:15:59.432Z
Learning: In React Router v7, `createBrowserRouter` and other router primitives should be imported from `react-router` package, not from `react-router-dom` as in previous versions. This represents a significant change in the library's structure where router primitives are now in the core package.
components/webui/server/src/plugins/external/mysql.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/routes/api/search/utils.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/routes/api/stream-files/index.ts (3)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
components/webui/server/src/routes/api/search/typings.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/schemas/stream-files.ts (3)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:35-41
Timestamp: 2024-11-19T19:52:43.429Z
Learning: For internal APIs in `components/log-viewer-webui/client/src/api/query.js`, runtime validation of parameters may not be necessary since the APIs are not exposed to end users, and JsDoc type annotations may be sufficient.
components/webui/server/src/plugins/app/StreamFileManager.ts (3)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
components/webui/server/src/plugins/app/QueryJobDbManager/index.ts (2)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts (4)
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:32-38
Timestamp: 2025-05-09T18:05:42.814Z
Learning: When implementing Socket.IO namespaces or connection pooling in a client-server architecture (like the MongoDB collection socket system in the log-viewer-webui), coordinated changes are needed on both client and server sides, making it appropriate to track as a TODO rather than implement piecemeal.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#892
File: components/log-viewer-webui/client/src/api/socket/MongoCollectionSocket.ts:27-31
Timestamp: 2025-05-09T19:15:26.180Z
Learning: For the MongoDB real-time updates implementation in components/log-viewer-webui/client/src/api/socket, a socket singleton pattern is used where a single shared socket connection is maintained rather than creating multiple connections. The socket lifecycle is managed centrally, with unsubscription handling in the useCursor React hook's cleanup function.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
components/webui/server/src/plugins/external/mongo.ts (2)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#647
File: components/log-viewer-webui/server/src/main.ts:8-8
Timestamp: 2024-12-31T19:19:55.032Z
Learning: When "moduleResolution": "node16" is used in a TypeScript project's tsconfig.json, the import file extension is typically expected to be ".js" (or ".cjs"/".mjs"), even if the source code is originally in TypeScript (.ts). This is a part of node16’s resolution behavior.
components/webui/server/src/routes/api/search/index.ts (1)
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/server/src/routes/static.ts (2)
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
components/webui/server/package.json (3)
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
components/webui/server/src/app.ts (3)
Learnt from: davemarco
PR: y-scope/clp#1015
File: components/log-viewer-webui/server/src/routes/static.ts:65-70
Timestamp: 2025-06-16T13:05:27.349Z
Learning: In components/log-viewer-webui/server/src/routes/static.ts, when decorateReply is set to true in fastifyStatic configuration, the reply.sendFile() method automatically uses the root directory configured in the static plugin registration, eliminating the need to pass the root directory as a second parameter.
Learnt from: junhaoliao
PR: y-scope/clp#939
File: components/package-template/src/etc/clp-config.yml:64-64
Timestamp: 2025-06-22T04:01:43.409Z
Learning: The new webui architecture uses Fastify with Pino logging instead of the previous Winston-based logging system that was removed during the webui refactoring.
Learnt from: junhaoliao
PR: y-scope/clp#899
File: components/log-viewer-webui/server/src/main.ts:50-58
Timestamp: 2025-05-13T19:38:31.164Z
Learning: When using Fastify's `app.close()` method, always wrap it in a try/catch block to properly handle shutdown errors. The close() method returns a Promise that can reject if errors occur during the shutdown process (especially with plugins using onClose hooks), and unhandled rejections could cause the application to hang.
🧬 Code Graph Analysis (1)
components/webui/server/src/app.ts (2)
components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts (1)
FastifyInstance
(408-410)components/webui/server/src/plugins/external/env.ts (1)
FastifyInstance
(6-15)
🪛 Biome (1.9.4)
components/webui/server/src/app.ts
[error] 29-29: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
🔇 Additional comments (12)
components/webui/server/src/plugins/external/mysql.ts (1)
7-8
: Import path confirmed
- The file
components/webui/server/settings.json
exists, so the import from../../../settings.json
will resolve correctly at runtime.- No code changes needed here—just ensure your build/packaging process includes this file in the shipped artefact.
components/webui/server/src/plugins/app/QueryJobDbManager/index.ts (1)
9-10
: Path tweaks look good – just make sure the JSON assertion remains transpile-safeBoth import paths were updated correctly and still honour Node 16’s
moduleResolution=node16
(note the retained.js
file-extension).
Nothing else to flag here.Also applies to: 16-17
components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts (1)
7-8
: Import relocation acknowledgedThe shortened path resolves correctly given the flattened directory structure.
components/webui/server/src/schemas/stream-files.ts (1)
3-5
: Import path adjustment LGTMThe schema file compiles and the enum reference remains intact.
components/webui/server/src/test/example.test.ts (1)
5-5
: Import path update approved – no legacy fastify-v2 references found
- Verified by running
rg --fixed-strings "../fastify-v2" components/webui/server
: ✓ No legacy paths found- The import in
components/webui/server/src/test/example.test.ts
remains correct:import routes from "../routes/api/example/index.js";components/webui/server/src/routes/api/stream-files/index.ts (1)
4-6
: Import rewiring verified
All three paths resolve correctly under the new directory layout; no issues spotted.components/webui/server/src/routes/api/search/typings.ts (1)
10-14
: Import-path adjustment looks correct – confirm build still resolves.The shorter relative path to
common/index.js
aligns with the directory flattening. As this repo usesmoduleResolution: "node16"
, exporting.js
is required and looks good. Please run a quicktsc --noEmit
to ensure no remaining files still point to the old deeper path.components/webui/server/src/plugins/external/mongo.ts (1)
3-3
: Path change approved, but validate settings file availability in packaged dist.Moving from
../../../../
→../../../
is correct after folder flattening. Double-check that the compiled output still copiessettings.json
into the same relative location (dist/server/settings.json
); otherwise Fastify-CLI will fail at runtime.components/webui/server/src/routes/api/search/index.ts (1)
7-13
: All three imports updated – run integration tests for safety.Nothing functionally changed, but this file is hot-path; a silent mis-path will surface only at runtime. Please execute the existing end-to-end search test suite (or hit
/api/search/query
) before merging.components/webui/server/package.json (1)
9-15
: Script target updated – confirmtsc
outDir matchesdist/server
.
tsc
defaultoutDir
is oftendist
. Because the start scripts now referencedist/server/src/app.js
, ensuretsconfig.json
sets"rootDir": "src"
and"outDir": "dist/server"
(or that a post-build move copies correctly). Otherwise production start will 404.components/webui/server/src/routes/static.ts (1)
40-55
: LGTM! Clean removal of environment-specific logic.The removal of the conditional check for production environment simplifies the code and makes it consistent with the other static directory registrations. The implementation correctly uses
decorateReply: true
which allowsreply.sendFile()
to work without specifying the root directory.components/webui/server/src/app.ts (1)
1-106
: Excellent Fastify app architecture with proper plugin loading and error handling.The migration to
fastifyAutoload
provides a clean, maintainable structure. The implementation includes:
- Proper plugin loading order (external → app → routes)
- Comprehensive error handling with detailed logging
- Security-conscious rate-limited 404 handler
|
||
import settings from "../../../../../settings.json" with {type: "json"}; | ||
import {Nullable} from "../../../../typings/common.js"; | ||
import settings from "../../../../settings.json" with {type: "json"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON import assertion syntax may not compile under Node ≥ 20 / TS ≥ 5.4
The current syntax uses the Stage-3 with {type: "json"}
clause. Node’s stable implementation – and TypeScript’s emit – expect assert { type: "json" }
. Unless your build pipeline rewrites this, the file will fail to transpile / run.
-import settings from "../../../../settings.json" with {type: "json"};
+import settings from "../../../../settings.json" assert { type: "json" };
Please verify the chosen syntax against the toolchain versions in CI.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import settings from "../../../../settings.json" with {type: "json"}; | |
-import settings from "../../../../settings.json" with {type: "json"}; | |
+import settings from "../../../../settings.json" assert { type: "json" }; |
🤖 Prompt for AI Agents
In components/webui/server/src/plugins/app/S3Manager/index.ts at line 8, the
JSON import uses the syntax 'with {type: "json"}' which may not be compatible
with Node.js version 20 or TypeScript 5.4 and above. Replace this with the
stable syntax 'assert { type: "json" }' to ensure compatibility and successful
transpilation. Verify this change works with the CI toolchain versions.
import settings from "../../../../../settings.json" with {type: "json"}; | ||
import {Nullable} from "../../../../typings/common.js"; | ||
import settings from "../../../../settings.json" with {type: "json"}; | ||
import {Nullable} from "../../../typings/common.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Importing “.js” from TypeScript may generate incorrect dist
paths
../../../typings/common.js
assumes your emitted files keep the same relative depth and extension mapping. When tsc
is configured with "module": "ESNext"
and outDir
, the compiled path often becomes ../../../typings/common.js
in the output directory, but the source file is common.ts
. If preserveExtensions
is not enabled the import will be wrong at runtime.
Recommend importing the bare module and let TS resolve the .ts
:
-import {Nullable} from "../../../typings/common.js";
+import {Nullable} from "../../../typings/common";
or add a paths
alias in tsconfig.json
to avoid brittle relative traversals.
🤖 Prompt for AI Agents
In components/webui/server/src/plugins/app/S3Manager/index.ts at line 9, the
import statement uses a .js extension which can cause incorrect paths in the
compiled output. To fix this, remove the .js extension from the import path so
TypeScript can resolve the .ts file correctly, or alternatively configure a path
alias in tsconfig.json to avoid fragile relative imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. This PR is only about moving existing files around.
Validations:
- For clp-text and clp-json
- Card display is correct
- Query works as expected
- Extract stream works
Question: This commit doesn't address the "Remove all node environment references from server" task, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deferring to @hoophalab 's review
|
Description
PR flattens fastify-v2 directory into src, and removes all references to V1 architecture. The PR also removes remaining NODE ENV references. This is a chain of PRs which started with #1027
Checklist
breaking change.
Validation performed
Tested webui in package
Summary by CodeRabbit
New Features
Refactor
Chores