Skip to content

Conversation

@yoannmoinet
Copy link
Member

@yoannmoinet yoannmoinet commented Mar 26, 2025

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.

  • streamlining server responses.
  • adding a middleware feature so yarn cli dev-server can implement its templating feature.
  • adding a routes feature so @dd/synthetics-plugin can implement its routes for inter communication with datadog-ci.

TODO

  • Add tests

@yoannmoinet yoannmoinet mentioned this pull request Mar 27, 2025
1 task
@yoannmoinet yoannmoinet marked this pull request as ready for review March 27, 2025 09:56
@yoannmoinet yoannmoinet requested review from Copilot and elbywan March 27, 2025 10:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Base automatically changed from yoann/change-plugin-init to master March 28, 2025 15:46
@yoannmoinet yoannmoinet merged commit 68c9fff into master Mar 28, 2025
4 checks passed
@yoannmoinet yoannmoinet deleted the yoann/move-dev-server branch March 28, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants