Custom endpoint typescript

I’m working on a custom endpoint in Directus, but instead of writing all the routes in index.ts, I want to separate different route groups into separate files for better code organization. However, I need to ensure that these separate route files can still access Directus services like ItemsService, schema, database, etc. I have searched for examples of custom endpoints, but most of the guides I found only cover basic setups. Are there any best practices or more advanced examples for structuring custom endpoints this way?

You could browse the marketplace or npm for directus extensions that are endpoints. As all extensions are open source, you might find others who already figured it out and go off of what they have done.