Skip to content
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

feat: use internal trees for prettyPrint #321

Merged
merged 5 commits into from
Mar 10, 2023

Conversation

ivan-tymoshenko
Copy link
Collaborator

@ivan-tymoshenko ivan-tymoshenko commented Mar 6, 2023

Fix: #315, #316, #271, #82

Problem: prettyPrint builds trees from scratch with a different algorithm. You can't use it for debugging and you always need to keep real trees and printed trees synced. It's literally another small router nested into the big one.

Solution: don't emulate the trees. I added a new option to the prettyPrint function: method. If you pass it, fmw will print you an internal tree. If you don't pass it, fmw will create a new router, merge all trees with a constraint hack, and will print the merged tree.

The logic of commonPrefix: false will be a little bit different.

+ a lot of bug fixing, refactoring

❗ It will require regenerating prettyPrint tests in Fastify. Mostly because of bug fixing.

cc @climba03003 @Eomm @mcollina

Copy link
Contributor

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

LGTM.
Just some advice on document changes.

README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Co-authored-by: KaKa <kaka@kakawebsitedemo.com>
Copy link
Contributor

@Eomm Eomm left a comment

Choose a reason for hiding this comment

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

Could you open a PR against fastify linking this branch to see the changes?

Comment on lines 334 to 335
└── /:hello (GET)
/:hello (PUT)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't the GET,PUT collapse good?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's doable, but Idk if it's a good idea. For me, it's more clear when each line/branch represents each node. But I'm the wrong person to ask as I don't use pretty print at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@ivan-tymoshenko ivan-tymoshenko marked this pull request as draft March 9, 2023 18:13
@ivan-tymoshenko ivan-tymoshenko marked this pull request as draft March 9, 2023 18:13
@ivan-tymoshenko ivan-tymoshenko marked this pull request as ready for review March 9, 2023 20:12
@ivan-tymoshenko
Copy link
Collaborator Author

@Eomm related PR in the Fastify: fastify/fastify#4618

@ivan-tymoshenko ivan-tymoshenko marked this pull request as draft March 9, 2023 20:55
@ivan-tymoshenko ivan-tymoshenko marked this pull request as ready for review March 9, 2023 23:35
@mcollina mcollina merged commit 3f9c2e5 into main Mar 10, 2023
@mcollina mcollina deleted the use-internal-trees-for-pretty-printing branch March 10, 2023 09:03
josephharrington added a commit to restify/node-restify that referenced this pull request Apr 20, 2023
This fixes tests related to a recent `find-my-way` release. The relevant
change is: delvedor/find-my-way#321
mmarchini pushed a commit to restify/node-restify that referenced this pull request Jun 18, 2023
This fixes tests related to a recent `find-my-way` release. The relevant
change is: delvedor/find-my-way#321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants