starknet-id / api.starknet.quest

starknet.quest rust backend
1 stars 14 forks source link

Update axum_auto_routes #236

Closed Marchand-Nicolas closed 3 weeks ago

Marchand-Nicolas commented 1 month ago

The aim of this issue is to simplify the way we handle http requests. More specifically, this is the routing system we want to improve, using the axum_auto_routes library: https://github.com/th0rgal/axum_auto_routes

Currently an outdated version of this lib is used which requires us to specify the path of the function (while instead you can now optionally specify middlewares)

ScottyDavies commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am front end developer with 6 years experience. i have worked with microsoft on several projects, this will be my first time contributing to the hackathon and i am ready to work

How I plan on tackling this issue

I would approach this issue with following steps

Set up a global route registry: In your main application, you need to set up a global route registry using a Mutex<Vec<Box>>. This registry will store the routes that will be registered with the Axum router. Implement the WithState trait: You need to implement the WithState trait for your Router type. This trait provides the to_router method to convert the Router into one that is associated with the shared application state. Use the #[route] macro: Annotate your async route handler functions with the #[route] macro, specifying the HTTP method and the route path. Optionally, you can also specify the module path if the function is not in the root module. Assemble the final Axum app: In your main function, you can then assemble the final Axum app by iterating over the ROUTE_REGISTRY, merging all the registered routes, and setting up the server.

PoulavBhowmick03 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a software engineer at Invisible Studios with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet community.

How I plan on tackling this issue

To update and simplify the routing system using the axum_auto_routes library, here’s how I would approach the problem:

1. Update the Dependency

2. Review Existing Routes

3. Refactor Route Registration

4. Add Middleware (Optional)

5. Test and Validate

6. Documentation and Cleanup

7. Deployment

This approach ensures a clean, maintainable routing system using the latest features of the axum_auto_routes library, making your codebase more robust and easier to manage.

ETA- 2 days

ShantelPeters commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

With a background in frontend and blockchain development, I've worked extensively with web technologies and libraries. I can leverage my experience to update the routing system by integrating the latest axum_auto_routes library, ensuring efficient handling of HTTP requests and improved code maintainability.

How I plan on tackling this issue

I would update the routing system by upgrading to the latest version of axum_auto_routes. This involves:

  1. Installing the Latest Version: Update dependencies to use the new library version with improved middleware options.
  2. Refactoring Code: Modify existing routes to leverage optional middleware configurations, simplifying function path specifications.
  3. Testing: Ensure all routes work as expected with the new setup, verifying compatibility and performance improvements.
onlydustapp[bot] commented 3 weeks ago

The maintainer Marchand-Nicolas has assigned PoulavBhowmick03 to this issue via OnlyDust Platform. Good luck!

PoulavBhowmick03 commented 3 weeks ago

Thanks! Will start working on it asap