Skip to content

Conversation

@TorstenDittmann
Copy link
Contributor

@TorstenDittmann TorstenDittmann commented Apr 4, 2023

What changed:

  • Added Router class, that uses key lookups in a key
  • Removed lots of unused code in utopia that was needed for route matching before
  • Added tests

Route Matching:

Each route is saved and each :param is replaced with a placeholder of :::

'/' => '/',
'/blog' => '/blog,
'/blog/authors' => '/blog/authors',
'/blog/categories' => '/blog/categories',
'/blog/:blogId' => '/blog/:::'
'/blog/:blogId/comments/add' => /blog/:blogId/comments/add'
'/blog/:blogId/comments/:commentId' => '/blog/:blogId/comments/:::'
}

Additionally, each index of params splitting by / is saved for performance, so 1 and 3 in this case for :blogId and :commentId.

Based on the path segments, the Router creates following strings when looking for /blog/lorem-ipsum/comments/532:

[
    '/blog/lorem-ipsum/comments/532',
    '/blog/:::/comments/532',
    '/blog/lorem-ipsum/comments/:::'
    '/blog/:::/comments/:::'
]

And can find the URL in a maximum of 4 key lookups.

Copy link
Member

@eldadfux eldadfux left a comment

Choose a reason for hiding this comment

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

I don't see any support for alias routes like we used to have, what is our approach for that now?

@TorstenDittmann TorstenDittmann marked this pull request as ready for review May 4, 2023 10:37
@lohanidamodar lohanidamodar requested a review from eldadfux July 27, 2023 00:40
@lohanidamodar lohanidamodar merged commit 1c8ed95 into master Jul 30, 2023
@TorstenDittmann TorstenDittmann deleted the feat-routing-v2 branch July 30, 2023 16:49
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.

🐛 Bug Report: Server sdk for node deleteFile api delete storage bucket instead of file.

4 participants