Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR extracts the dev server functionality into a shared helper module to streamline server responses and support middleware and routing for the upcoming synthetics plugin integration.
- Moved file serving logic from the dev-server command to a new server helper.
- Introduced middleware support for templating and logging modifications.
- Added basic routing in the server helper for future inter-component communication.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/tools/src/commands/dev-server/index.ts | Updated to use the new runServer helper with middleware support replacing inlined file serving. |
| packages/core/src/helpers/server.ts | New helper module centralizing file preparation, server creation, and route handling. |
Comments suppressed due to low confidence (2)
packages/tools/src/commands/dev-server/index.ts:110
- [nitpick] Consider renaming the variable 'c' to 'statusColor' for improved clarity.
const c = { 200: chalk.green, 404: chalk.yellow.bold, 500: chalk.red.bold }[statusCode] || chalk.white;
packages/core/src/helpers/server.ts:57
- The staticPath is resolved using process.cwd() here, whereas the original dev-server logic used the ROOT constant. This discrepancy might lead to inconsistent behavior if process.cwd() differs from ROOT.
const staticPath = root ? path.isAbsolute(root) ? root : path.resolve(process.cwd(), root) : process.cwd();
Ayc0
approved these changes
Mar 28, 2025
elbywan
approved these changes
Mar 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on
What and why?
In preparation of [feat] Add synthetics plugin we extract the dev server implementation into a core helper.
How?
It's mostly a code move with some small additions to allow for a more basic utilisation.
middlewarefeature soyarn cli dev-servercan implement its templating feature.routesfeature so@dd/synthetics-plugincan implement its routes for inter communication withdatadog-ci.TODO